├── .eslintignore ├── .eslintrc ├── .github ├── accessory-checkmark.png ├── accessory-detail-button.png ├── accessory-disclosure-button.png ├── accessory-disclosure-indicator.png ├── accessory-none.png ├── bundled-json-example.gif ├── cell-style-default.png ├── cell-style-subtitle.png ├── cell-style-value1.png ├── cell-style-value2.png ├── editing-example.gif ├── large-network-example.gif ├── pull-to-refresh-example.gif ├── tableview-grouped.png └── tableview-plain.png ├── .gitignore ├── .npmignore ├── .prettierrc ├── LICENSE ├── README.md ├── RNTableView.podspec ├── RNTableView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ ├── RCTSvg.xccheckout │ │ ├── RCTTableView.xccheckout │ │ └── RNTableView.xccheckout │ └── xcuserdata │ │ ├── aksonov.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── WorkspaceSettings.xcsettings │ │ ├── nickwientge.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ ├── sjchmiela.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── zhangjilong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── aksonov.xcuserdatad │ └── xcschemes │ │ ├── RCTTableView.xcscheme │ │ └── xcschememanagement.plist │ ├── nickwientge.xcuserdatad │ └── xcschemes │ │ ├── RNTableView.xcscheme │ │ └── xcschememanagement.plist │ ├── sjchmiela.xcuserdatad │ └── xcschemes │ │ ├── RNTableView.xcscheme │ │ └── xcschememanagement.plist │ └── zhangjilong.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── RNTableView.xcscheme │ └── xcschememanagement.plist ├── RNTableView ├── JSONDataSource.h ├── JSONDataSource.m ├── RNAppGlobals.h ├── RNAppGlobals.m ├── RNCellView.h ├── RNCellView.m ├── RNCellViewManager.h ├── RNCellViewManager.m ├── RNReactModuleCell.h ├── RNReactModuleCell.m ├── RNTableFooterView.h ├── RNTableFooterView.m ├── RNTableFooterViewManager.h ├── RNTableFooterViewManager.m ├── RNTableHeaderView.h ├── RNTableHeaderView.m ├── RNTableHeaderViewManager.h ├── RNTableHeaderViewManager.m ├── RNTableView.h ├── RNTableView.m ├── RNTableViewCell.h ├── RNTableViewCell.m ├── RNTableViewManager.h └── RNTableViewManager.m ├── example ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── __tests__ │ └── App-test.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── tableviewdemo │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── Podfile.lock │ ├── TableViewDemo-tvOS │ │ └── Info.plist │ ├── TableViewDemo-tvOSTests │ │ └── Info.plist │ ├── TableViewDemo.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── TableViewDemo-tvOS.xcscheme │ │ │ └── TableViewDemo.xcscheme │ ├── TableViewDemo.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── TableViewDemo │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── TableViewDemoTests │ │ ├── Info.plist │ │ └── TableViewDemoTests.m ├── metro.config.js ├── package.json ├── src │ ├── assets │ │ └── states.json │ ├── cells │ │ └── TableViewExampleCell.js │ ├── index.js │ └── screens │ │ ├── Example1.js │ │ ├── Example2.js │ │ ├── Example3.js │ │ ├── Example4.js │ │ ├── Example5.js │ │ ├── Example6.js │ │ ├── Example7.js │ │ ├── Example8.js │ │ └── Home.js └── yarn.lock ├── package.json ├── src ├── TableView.js ├── TableViewCell.js ├── TableViewConsts.js ├── TableViewFooter.js ├── TableViewHeader.js ├── TableViewItem.js ├── TableViewSection.js ├── index.d.ts ├── index.js └── util │ └── ViewPropTypes.js └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@react-native-community", 3 | "rules": { 4 | "react-native/no-inline-styles": 0 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.github/accessory-checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/accessory-checkmark.png -------------------------------------------------------------------------------- /.github/accessory-detail-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/accessory-detail-button.png -------------------------------------------------------------------------------- /.github/accessory-disclosure-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/accessory-disclosure-button.png -------------------------------------------------------------------------------- /.github/accessory-disclosure-indicator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/accessory-disclosure-indicator.png -------------------------------------------------------------------------------- /.github/accessory-none.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/accessory-none.png -------------------------------------------------------------------------------- /.github/bundled-json-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/bundled-json-example.gif -------------------------------------------------------------------------------- /.github/cell-style-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/cell-style-default.png -------------------------------------------------------------------------------- /.github/cell-style-subtitle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/cell-style-subtitle.png -------------------------------------------------------------------------------- /.github/cell-style-value1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/cell-style-value1.png -------------------------------------------------------------------------------- /.github/cell-style-value2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/cell-style-value2.png -------------------------------------------------------------------------------- /.github/editing-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/editing-example.gif -------------------------------------------------------------------------------- /.github/large-network-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/large-network-example.gif -------------------------------------------------------------------------------- /.github/pull-to-refresh-example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/pull-to-refresh-example.gif -------------------------------------------------------------------------------- /.github/tableview-grouped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/tableview-grouped.png -------------------------------------------------------------------------------- /.github/tableview-plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/.github/tableview-plain.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | 56 | .vscode/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example/ 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "es5" 4 | } 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, aksonov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

React Native TableView

2 | 3 |

Native iOS UITableView for React Native with JSON support 4 | 5 |

6 | 7 | npm version 8 | 9 | 10 | npm downloads 11 | 12 | 13 | code style: prettier 14 | 15 |

16 | 17 | ## Contents 18 | 19 | - [Features](#features) 20 | - [Installation](#installation) 21 | - [Styles](#supported-styles) 22 | - [Examples](#examples) 23 | - [Customization](#customization) 24 | 25 | ## Features 26 | 27 | - Look and feel of iOS TableView - **because it is!** (with group/plain 28 | tableview type, sections headers, etc) 29 | - Display long lists of data (like country list) with no performance loss 30 | - Built-in accessory types (checkmark or disclosure indicator) 31 | - Pull to refresh! 32 | - Automatic scroll to initial selected value during component initialization 33 | (autoFocus property) 34 | - Automatic item selection with "checkmark" with old item de-selection 35 | (optionally), see demo, useful to select country/state/etc. 36 | - Render Native Section Index Titles (sectionIndexTitlesEnabled property) 37 | - Native JSON support for datasource. If you need to display large dataset, 38 | generated Javascript will became very large and impact js loading time. To 39 | solve this problem the component could read JSON directly from app bundle 40 | without JS! 41 | - Filter JSON datasources using NSPredicate syntax. For example you could select 42 | states for given country only (check demo) 43 | - Create custom UITableView cells with flexible height using React Native syntax 44 | (TableView.Cell tag) 45 | - Use TableView as menu to navigate to other screens (check included demo, using 46 | react-navigation https://reactnavigation.org) 47 | - Native editing mode for table - move/delete option is supported by using 48 | attributes canMove, canEdit for items/sections 49 | 50 | ## Installation 51 | 52 | Using npm: 53 | 54 | ```bash 55 | npm install react-native-tableview --save 56 | ``` 57 | 58 | or using yarn: 59 | 60 | ```bash 61 | yarn add react-native-tableview 62 | ``` 63 | 64 | > ⚠️ If you are on React Native < 0.60.0, you must use version 2.x.x of this library 65 | 66 | ### Pods 67 | 68 | > If using CocoaPods or React Native version >= 0.60.0 69 | 70 | ```bash 71 | cd ios && pod install && cd .. 72 | ``` 73 | 74 | ### Linking 75 | 76 | > For React Native <= 0.59 only 77 | 78 | ```bash 79 | react-native link react-native-tableview 80 | ``` 81 | 82 | If fails, follow manual linking steps below, 83 | 84 | #### Manual Linking 85 | 86 | 1. In XCode, in the project navigator, right click Libraries ➜ Add Files to 87 | [your project's name] 88 | 2. Add ./node_modules/react-native-tableview/RNTableView.xcodeproj 89 | 3. In the XCode project navigator, select your project, select the Build Phases 90 | tab and in the Link Binary With Libraries section add libRNTableView.a 91 | 4. And in the Build Settings tab in the Search Paths/Header Search Paths section 92 | add \$(SRCROOT)/../node_modules/react-native-tableview (make sure it's 93 | recursive). 94 | 95 | ## Supported Styles 96 | 97 | ### UITableView styles 98 | 99 | These values are provided to the `tableViewStyle` prop. 100 | 101 | ```jsx 102 | 103 | ``` 104 | 105 | | Style | Value | Preview | 106 | | ------- | -------------------------------- | -------------------------------------------- | 107 | | Plain | `TableView.Consts.Style.Plain` | ![alt text](./.github/tableview-plain.png) | 108 | | Grouped | `TableView.Consts.Style.Grouped` | ![alt text](./.github/tableview-grouped.png) | 109 | 110 | ### UITableViewCell styles 111 | 112 | These values are provided to the `tableViewCellStyle` prop. 113 | 114 | ```jsx 115 | 116 | ``` 117 | 118 | | Style | Value | Preview | 119 | | -------- | ------------------------------------- | ---------------------------------------------- | 120 | | Default | `TableView.Consts.CellStyle.Default` | ![alt text](./.github/cell-style-default.png) | 121 | | Value1 | `TableView.Consts.CellStyle.Value1` | ![alt text](./.github/cell-style-value1.png) | 122 | | Value2 | `TableView.Consts.CellStyle.Value2` | ![alt text](./.github/cell-style-value2.png) | 123 | | Subtitle | `TableView.Consts.CellStyle.Subtitle` | ![alt text](./.github/cell-style-subtitle.png) | 124 | 125 | ### Accessory types 126 | 127 | These values are provided to the `accessoryType` prop on the `Item`. 128 | 129 | ```jsx 130 | 131 | ``` 132 | 133 | | Style | Value | Preview | 134 | | -------------------- | ---------------------------------------------------- | --------------------------------------------------------- | 135 | | None | `TableView.Consts.AccessoryType.None` | ![alt text](./.github/accessory-none.png) | 136 | | Disclosure Indicator | `TableView.Consts.AccessoryType.DisclosureIndicator` | ![alt text](./.github/accessory-disclosure-indicator.png) | 137 | | Disclosure Button | `TableView.Consts.AccessoryType.DisclosureButton` | ![alt text](./.github/accessory-disclosure-button.png) | 138 | | Checkmark | `TableView.Consts.AccessoryType.Checkmark` | ![alt text](./.github/accessory-checkmark.png) | 139 | | Detail Button | `TableView.Consts.AccessoryType.DetailButton` | ![alt text](./.github/accessory-detail-button.png) | 140 | 141 | Disclosure Indicator can also be applied by adding the `arrow` prop on the 142 | section. 143 | 144 | ```jsx 145 |
146 | ``` 147 | 148 | Checkmark can also be applied by adding the `selected` prop on the Item. 149 | 150 | ```jsx 151 | 152 | ``` 153 | 154 | ### Props 155 | 156 | For a full list of props on all components check out 157 | [the typescript definitions file](./src/index.d.ts). 158 | 159 | ### Methods 160 | 161 | #### `scrollTo()` 162 | 163 | Scrolls to a set of coordinates on the tableview. 164 | 165 | ```ts 166 | /** 167 | * @param x Horizontal pixels to scroll 168 | * @param y Vertical pixels to scroll 169 | * @param animated With animation or not 170 | */ 171 | scrollTo(x: number, y: number, animated: boolean): void; 172 | ``` 173 | 174 | #### `scrollToIndex()` 175 | 176 | Scroll to an item in a section 177 | 178 | ```ts 179 | /** 180 | * @param params scroll params 181 | * @param params.index index of the cell 182 | * @param params.section index of the section @default 0 183 | * @param params.animated scroll with animation @default true 184 | */ 185 | scrollToIndex(params: { index: number, section?: number, animated?: boolean }): void; 186 | ``` 187 | 188 | ### List item format 189 | 190 | Items in the list can be either `TableView.Item` or `TableView.Cell`. An `Item` 191 | is simply text. A `Cell` can be any complex component. However, only `Item`s can 192 | be edited or moved. There are also issues with `Cell`s re-rendering on data 193 | changes (#19) that can be avoided by using `Item`s. If you want to be able to 194 | re-render, edit or move a complex component, use `reactModuleForCell`, described 195 | in [Editable Complex Components](#editable-complex-components). 196 | 197 | ## Examples 198 | 199 | ### Smooth scrolling with large network loaded list 200 | 201 | ![demo-3](./.github/large-network-example.gif) 202 | 203 | ```jsx 204 | () => { 205 | const [loading, setLoading] = useState(true); 206 | const [users, setUsers] = useState([]); 207 | 208 | useEffect(() => { 209 | const getUsers = async () => { 210 | const response = await fetch('https://randomuser.me/api/?results=5000'); 211 | const data = await response.json(); 212 | 213 | setLoading(false); 214 | setUsers( 215 | data.results.map(a => ({ 216 | name: `${a.name.first} ${a.name.last}`, 217 | id: a.registered, 218 | })) 219 | ); 220 | }; 221 | 222 | getUsers(); 223 | }, []); 224 | 225 | return ( 226 | 227 | 228 | {loading ? 'Fetching' : 'Fetched'} 5000 users 229 | 230 | 231 | {loading && } 232 | 233 | 237 |
238 | {users.map(a => ( 239 | {a.name} 240 | ))} 241 |
242 |
243 |
244 | ); 245 | }; 246 | ``` 247 | 248 | ### App-bundled JSON with filter and selected value checkmarked 249 | 250 | ![editing example](./.github/bundled-json-example.gif) 251 | 252 | ```jsx 253 | // list spanish provinces and add 'All states' item at the beginning 254 | 255 | const country = 'ES'; 256 | 257 | return ( 258 | 259 | Showing States in Spain 260 | alert(JSON.stringify(event))} 267 | /> 268 | 269 | ); 270 | ``` 271 | 272 | ### Built-in editing 273 | 274 | ![editing example](./.github/editing-example.gif) 275 | 276 | ```jsx 277 | render() { 278 | return ( 279 | 280 | 284 |
285 | Item 1 286 | Item 2 287 | Item 3 288 | Item 4 289 | Item 5 290 | Item 6 291 | Item 7 292 | Item 8 293 |
294 |
295 |
296 | ) 297 | } 298 | ``` 299 | 300 | ### Pull to Refresh 301 | 302 | ![pull to refresh example](./.github/pull-to-refresh-example.gif) 303 | 304 | ```jsx 305 | function reducer(state, action) { 306 | switch (action.type) { 307 | case 'getUsers': 308 | return { ...state, loading: false, users: action.payload }; 309 | case 'startRefresh': 310 | return { ...state, refreshing: true }; 311 | case 'endRefresh': 312 | return { 313 | ...state, 314 | refreshing: false, 315 | amount: state.amount + 10, 316 | users: [...state.users, ...action.payload], 317 | }; 318 | default: 319 | return state; 320 | } 321 | } 322 | 323 | () => { 324 | const [{ loading, amount, refreshing, users }, dispatch] = useReducer( 325 | reducer, 326 | { 327 | loading: true, 328 | users: [], 329 | refreshing: false, 330 | amount: 10, 331 | } 332 | ); 333 | 334 | useEffect(() => { 335 | const getUsers = async () => { 336 | const data = await fetchUsers(); 337 | dispatch({ type: 'getUsers', payload: data }); 338 | }; 339 | 340 | getUsers(); 341 | }, []); 342 | 343 | const fetchUsers = async () => { 344 | const response = await fetch('https://randomuser.me/api/?results=10'); 345 | const data = await response.json(); 346 | 347 | return data.results.map(a => ({ 348 | name: `${a.name.first} ${a.name.last}`, 349 | id: a.login.uuid, 350 | })); 351 | }; 352 | 353 | const fetchMore = async () => { 354 | dispatch({ type: 'startRefresh' }); 355 | const data = await fetchUsers(); 356 | dispatch({ type: 'endRefresh', payload: data }); 357 | }; 358 | 359 | return ( 360 | 361 | 362 | {loading ? 'Fetching' : 'Fetched'} {amount} users 363 | 364 | 365 | {loading && } 366 | 367 | 374 |
375 | {users.map(a => ( 376 | {a.name} 377 | ))} 378 |
379 |
380 |
381 | ); 382 | }; 383 | } 384 | ``` 385 | 386 | ## Customization 387 | 388 | The following style props are supported: 389 | 390 | - `tableViewCellStyle` 391 | - `tableViewCellEditingStyle` 392 | - `separatorStyle` 393 | - `contentInset` 394 | - `contentOffset` 395 | - `scrollIndicatorInsets` 396 | - `cellLayoutMargins` 397 | - `cellSeparatorInset` 398 | 399 | Colors: 400 | 401 | - `textColor` 402 | - `tintColor` 403 | - `selectedTextColor` 404 | - `detailTextColor` 405 | - `separatorColor` 406 | - `headerTextColor` 407 | - `headerBackgroundColor` 408 | - `footerTextColor` 409 | 410 | Base font: 411 | 412 | - `fontSize` 413 | - `fontWeight` 414 | - `fontStyle` 415 | - `fontFamily` 416 | 417 | "Subtitle" font: 418 | 419 | - `detailFontSize` 420 | - `detailFontWeight` 421 | - `detailFontStyle` 422 | - `detailFontFamily` 423 | 424 | Header font: 425 | 426 | - `headerFontSize` 427 | - `headerFontWeight` 428 | - `headerFontStyle` 429 | - `headerFontFamily` 430 | 431 | Footer font: 432 | 433 | - `footerFontSize` 434 | - `footerFontWeight` 435 | - `footerFontStyle` 436 | - `footerFontFamily` 437 | 438 | ## Images / Icons 439 | 440 | An `Item` component takes an `image` and an optional `imageWidth` prop. 441 | 442 | An `image` prop can be a string pointing to the name of an asset in your "Asset 443 | Catalog". In this case an `imageWidth` prop is recommended. 444 | 445 | ```jsx 446 | 447 | ``` 448 | 449 | Alternatively, you can `require` the image from your local app code. In this case 450 | an `imageWidth` is unnecessary. 451 | 452 | ```jsx 453 | 454 | ``` 455 | 456 | ### Editable Complex Components 457 | 458 | Only `Item`s can be edited or moved. However you can create a complex component 459 | that is referenced by an Item using `reactModuleForCell`. You will need to do 460 | several things to set this up. 461 | 462 | 1. Write your view component. 463 | 2. Pass the name of your view component as a prop in your `` 464 | component. 465 | 3. Create a list of ``s in your TableView, passing props intended for your 466 | view component. 467 | 4. Register your view component as an `App` root view. 468 | 469 | ### Write your cell view component. 470 | 471 | For example, 472 | 473 | ```jsx 474 | //Should be pure... setState on top-level component doesn't seem to work 475 | 476 | class TableViewExampleCell extends React.Component { 477 | render() { 478 | var style = { borderColor: '#aaaaaa', borderWidth: 1, borderRadius: 3 }; 479 | 480 | // Fill the full native table cell height. 481 | style.flex = 1; 482 | 483 | // All Item props get passed to this cell inside this.props.data. Use them to control the rendering, for example background color: 484 | if (this.props.data.backgroundColor !== undefined) { 485 | style.backgroundColor = this.props.data.backgroundColor; 486 | } 487 | 488 | return ( 489 | 490 | 491 | section:{this.props.section},row:{this.props.row},label: 492 | {this.props.data.label} 493 | 494 | message:{this.props.data.message} 495 | 496 | ); 497 | } 498 | } 499 | ``` 500 | 501 | For more examples, see examples/TableViewDemo. 502 | 503 | #### Pass component as prop. 504 | 505 | ```jsx 506 | 507 | ``` 508 | 509 | #### Create list of items, passing props 510 | 511 | ```jsx 512 |
513 | {this.props.items.map(function(item) { 514 | return ( 515 | 520 | ); 521 | })} 522 |
523 | ``` 524 | 525 | Note that the props you pass must be primitive types: they cannot be objects. 526 | Also, note that the props become properties of the `data` prop in your 527 | `reactModuleForCell` component. That is, you pass `label="foo"` and in your 528 | component you pick it up as `this.props.data.label`. 529 | 530 | #### Register your component. 531 | 532 | Each cell you render becomes a reuseable root view or `App`. 533 | 534 | ```js 535 | var { AppRegistry } = React; 536 | 537 | ... 538 | 539 | AppRegistry.registerComponent('TableViewExample', () => TableViewExample); 540 | ``` 541 | 542 | When debugging, you will see the message: 543 | 544 | ``` 545 | Running application "TableViewExample" with appParams: { /* params */ }. __DEV__ === true, development-level warning are ON, performance optimizations are OFF 546 | ``` 547 | 548 | multiple times. While slightly annoying, this does not seem to affect 549 | performance. You may also see message 550 | [Unbalanced calls start/end for tag 5](https://github.com/facebook/react-native/issues/4163). 551 | -------------------------------------------------------------------------------- /RNTableView.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 3 | 4 | Pod::Spec.new do |s| 5 | s.name = "RNTableView" 6 | s.version = package["version"] 7 | s.authors = "Pavel Aksonov" 8 | s.summary = package["description"] 9 | s.license = package["license"] 10 | s.homepage = package["homepage"] 11 | s.platform = :ios, "7.0" 12 | s.source = { :git => package["repository"]["url"] } 13 | s.source_files = 'RNTableView/*.{h,m}' 14 | s.preserve_paths = "**/*.js" 15 | s.dependency 'React' 16 | 17 | end 18 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcshareddata/RCTSvg.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 7347E3AC-5C8C-4DD5-9272-3FFFE9860DB1 9 | IDESourceControlProjectName 10 | RCTSvg 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 315E056E8429F8CF8B34998964C5F52485938FC8 14 | https://github.com/aksonov/react-native-tableview.git 15 | A72D15A13D4BC274BA37FFC66F348F91C5860448 16 | https://github.com/aksonov/react-native-svg-elements.git 17 | 18 | IDESourceControlProjectPath 19 | RCTSvg.xcodeproj 20 | IDESourceControlProjectRelativeInstallPathDictionary 21 | 22 | 315E056E8429F8CF8B34998964C5F52485938FC8 23 | ../.. 24 | A72D15A13D4BC274BA37FFC66F348F91C5860448 25 | ../../../react-native-svg-elements 26 | 27 | IDESourceControlProjectURL 28 | https://github.com/aksonov/react-native-tableview.git 29 | IDESourceControlProjectVersion 30 | 111 31 | IDESourceControlProjectWCCIdentifier 32 | 315E056E8429F8CF8B34998964C5F52485938FC8 33 | IDESourceControlProjectWCConfigurations 34 | 35 | 36 | IDESourceControlRepositoryExtensionIdentifierKey 37 | public.vcs.git 38 | IDESourceControlWCCIdentifierKey 39 | A72D15A13D4BC274BA37FFC66F348F91C5860448 40 | IDESourceControlWCCName 41 | react-native-svg-elements 42 | 43 | 44 | IDESourceControlRepositoryExtensionIdentifierKey 45 | public.vcs.git 46 | IDESourceControlWCCIdentifierKey 47 | 315E056E8429F8CF8B34998964C5F52485938FC8 48 | IDESourceControlWCCName 49 | react-native-tableview 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcshareddata/RCTTableView.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 2694DE57-3658-4B59-9101-847DE776209B 9 | IDESourceControlProjectName 10 | RCTTableView 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 315E056E8429F8CF8B34998964C5F52485938FC8 14 | https://github.com/aksonov/react-native-tableview.git 15 | 16 | IDESourceControlProjectPath 17 | RCTTableView.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 315E056E8429F8CF8B34998964C5F52485938FC8 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/aksonov/react-native-tableview.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 315E056E8429F8CF8B34998964C5F52485938FC8 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 315E056E8429F8CF8B34998964C5F52485938FC8 36 | IDESourceControlWCCName 37 | react-native-tableview 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcshareddata/RNTableView.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 51ADF4A8-6EF3-41C9-AB24-CB7DD5A07127 9 | IDESourceControlProjectName 10 | RNTableView 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 315E056E8429F8CF8B34998964C5F52485938FC8 14 | https://github.com/aksonov/react-native-tableview.git 15 | 16 | IDESourceControlProjectPath 17 | RNTableView.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 315E056E8429F8CF8B34998964C5F52485938FC8 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/aksonov/react-native-tableview.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 315E056E8429F8CF8B34998964C5F52485938FC8 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 315E056E8429F8CF8B34998964C5F52485938FC8 36 | IDESourceControlWCCName 37 | react-native-tableview 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcuserdata/aksonov.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/RNTableView.xcodeproj/project.xcworkspace/xcuserdata/aksonov.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcuserdata/aksonov.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcuserdata/nickwientge.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/RNTableView.xcodeproj/project.xcworkspace/xcuserdata/nickwientge.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcuserdata/sjchmiela.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/RNTableView.xcodeproj/project.xcworkspace/xcuserdata/sjchmiela.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTableView.xcodeproj/project.xcworkspace/xcuserdata/zhangjilong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/RNTableView.xcodeproj/project.xcworkspace/xcuserdata/zhangjilong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/aksonov.xcuserdatad/xcschemes/RCTTableView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/aksonov.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RCTTableView.xcscheme 8 | 9 | orderHint 10 | 2 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 873769941B7CD6E900F7C3C2 16 | 17 | primary 18 | 19 | 20 | 8737699F1B7CD6E900F7C3C2 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/nickwientge.xcuserdatad/xcschemes/RNTableView.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 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/nickwientge.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNTableView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 873769941B7CD6E900F7C3C2 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/sjchmiela.xcuserdatad/xcschemes/RNTableView.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 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/sjchmiela.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNTableView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 873769941B7CD6E900F7C3C2 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/zhangjilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/zhangjilong.xcuserdatad/xcschemes/RNTableView.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 | -------------------------------------------------------------------------------- /RNTableView.xcodeproj/xcuserdata/zhangjilong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNTableView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 873769941B7CD6E900F7C3C2 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /RNTableView/JSONDataSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONCountryDataSource.h 3 | // TableViewDemo 4 | // 5 | // Created by Pavlo Aksonov on 18.08.15. 6 | // Copyright (c) 2015 Facebook. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RNTableView.h" 11 | 12 | @interface JSONDataSource : NSObject 13 | 14 | -(id)initWithDictionary:(NSDictionary *)params; 15 | -(id)initWithFilename:(NSString *)file filter:(NSString *)filter args:(NSArray *)args; 16 | @property (nonatomic, strong) NSArray *sections; 17 | @end 18 | -------------------------------------------------------------------------------- /RNTableView/JSONDataSource.m: -------------------------------------------------------------------------------- 1 | // 2 | // JSONCountryDataSource.m 3 | // TableViewDemo 4 | // 5 | // Created by Pavlo Aksonov on 18.08.15. 6 | // Copyright (c) 2015 Facebook. All rights reserved. 7 | // 8 | 9 | #import "JSONDataSource.h" 10 | 11 | @implementation JSONDataSource 12 | -(id)initWithFilename:(NSString *)filename filter:(NSString *)filter args:(NSArray *)filterArgs { 13 | NSString *jsonPath = [[NSBundle mainBundle] pathForResource:filename 14 | ofType:@"json"]; 15 | 16 | NSAssert(jsonPath, @"Filename %@ doesn't exist within app bundle", filename); 17 | NSData *data = [NSData dataWithContentsOfFile:jsonPath]; 18 | NSError *error = nil; 19 | NSArray *json = (NSArray *)[NSJSONSerialization JSONObjectWithData:data 20 | options:NSJSONReadingMutableContainers 21 | error:&error]; 22 | 23 | NSAssert(error==nil, @"JSON Error %@", [error description]); 24 | NSAssert([json isKindOfClass:[NSArray class]], @"JSON should be NSArray type"); 25 | 26 | if (filter){ 27 | for (NSMutableDictionary *sections in json){ 28 | sections[@"items"] = [sections[@"items"] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:filter argumentArray:filterArgs]]; 29 | } 30 | } 31 | 32 | _sections = json; 33 | return self; 34 | } 35 | 36 | -(id)initWithDictionary:(NSDictionary *)params { 37 | NSString *filename = params[@"filename"]; 38 | NSAssert(filename, @"Filename should be defined"); 39 | return [self initWithFilename:filename filter:params[@"filter"] args:params[@"args"]]; 40 | } 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /RNTableView/RNAppGlobals.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | @class RCTBridge; 4 | 5 | @interface RNAppGlobals : NSObject { 6 | RCTBridge *appBridge; 7 | } 8 | 9 | @property (nonatomic, retain) RCTBridge *appBridge; 10 | 11 | + (id)sharedInstance; 12 | 13 | @end -------------------------------------------------------------------------------- /RNTableView/RNAppGlobals.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNGlobals.m 3 | // RNTableView 4 | // 5 | // Created by Anna Berman on 2/10/16. 6 | // Copyright © 2016 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNAppGlobals.h" 10 | 11 | @implementation RNAppGlobals 12 | 13 | @synthesize appBridge; 14 | 15 | + (id)sharedInstance { 16 | NSLog(@"RNAppGlobals is deprecated/no longer needed and will be removed soon"); 17 | 18 | static RNAppGlobals *instance = nil; 19 | static dispatch_once_t onceToken; 20 | dispatch_once(&onceToken, ^{ 21 | instance = [[self alloc] init]; 22 | }); 23 | return instance; 24 | } 25 | 26 | @end -------------------------------------------------------------------------------- /RNTableView/RNCellView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTCell.h 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RNTableViewCell.h" 11 | 12 | @class RNTableViewCell; 13 | 14 | @interface RNCellView : UIView 15 | 16 | @property (nonatomic) NSInteger row; 17 | @property (nonatomic) NSInteger section; 18 | @property (nonatomic) float componentHeight; 19 | @property (nonatomic) float componentWidth; 20 | @property (nonatomic, weak) UITableView *tableView; 21 | @property (nonatomic, strong) RNTableViewCell *tableViewCell; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /RNTableView/RNCellView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTCell.m 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNCellView.h" 10 | 11 | @implementation RNCellView 12 | 13 | 14 | -(void)setTableView:(UITableView *)tableView { 15 | _tableView = tableView; 16 | _tableViewCell = [[RNTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CustomCell"]; 17 | _tableViewCell.cellView = self; 18 | } 19 | 20 | -(void)setComponentHeight:(float)componentHeight { 21 | _componentHeight = componentHeight; 22 | if (componentHeight){ 23 | [_tableView reloadData]; 24 | } 25 | } 26 | 27 | /* 28 | // Only override drawRect: if you perform custom drawing. 29 | // An empty implementation adversely affects performance during animation. 30 | - (void)drawRect:(CGRect)rect { 31 | // Drawing code 32 | } 33 | */ 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /RNTableView/RNCellViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTCellViewManager.h 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNCellViewManager : RCTViewManager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RNTableView/RNCellViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTCellViewManager.m 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNCellViewManager.h" 10 | #import "RNCellView.h" 11 | 12 | @implementation RNCellViewManager 13 | RCT_EXPORT_MODULE() 14 | - (UIView *)view 15 | { 16 | return [[RNCellView alloc] init]; 17 | } 18 | 19 | RCT_EXPORT_VIEW_PROPERTY(row, NSInteger) 20 | RCT_EXPORT_VIEW_PROPERTY(section, NSInteger) 21 | RCT_EXPORT_VIEW_PROPERTY(componentHeight, float) 22 | RCT_EXPORT_VIEW_PROPERTY(componentWidth, float) 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /RNTableView/RNReactModuleCell.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | //Use react-native root views as reusable cells returned from cellForRowAtIndexPath. 5 | 6 | //App must use the code below to store the app bridge, else cells will be blank 7 | //AppDelegate.m, didFinishLaunchingWithOptions: 8 | // #import 9 | //RCTRootView *rootView = ... 10 | //[[RNAppGlobals sharedInstance] setAppBridge:rootView.bridge]; 11 | 12 | @interface RNReactModuleCell : UITableViewCell { 13 | } 14 | 15 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier bridge:(RCTBridge*) bridge data:(NSDictionary*)data indexPath:(NSIndexPath*)indexPath reactModule:(NSString*)reactModule tableViewTag:(NSNumber*)reactTag; 16 | 17 | -(void)setUpAndConfigure:(NSDictionary*)data bridge:(RCTBridge*)bridge indexPath:(NSIndexPath*)indexPath reactModule:(NSString*)reactModule tableViewTag:(NSNumber*)reactTag; 18 | 19 | @end -------------------------------------------------------------------------------- /RNTableView/RNReactModuleCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNReactModuleCell.m 3 | // RNTableView 4 | // 5 | // Created by Anna Berman on 2/6/16. 6 | // Copyright © 2016 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RNReactModuleCell.h" 11 | #import "RNTableView.h" 12 | 13 | @implementation RNReactModuleCell { 14 | RCTRootView *_rootView; 15 | } 16 | 17 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier bridge:(RCTBridge*) bridge data:(NSDictionary*)data indexPath:(NSIndexPath*)indexPath reactModule:(NSString*)reactModule tableViewTag:(NSNumber*)reactTag 18 | { 19 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 20 | if (self) { 21 | [self setUpAndConfigure:data bridge:bridge indexPath:indexPath reactModule:reactModule tableViewTag:reactTag]; 22 | } 23 | return self; 24 | } 25 | 26 | -(NSDictionary*) toProps:(NSDictionary *)data indexPath:(NSIndexPath*)indexPath reactTag:(NSNumber*)reactTag { 27 | return @{@"data":data, @"section":[[NSNumber alloc] initWithLong:indexPath.section], @"row":[[NSNumber alloc] initWithLong:indexPath.row], @"tableViewReactTag":reactTag}; 28 | } 29 | 30 | -(void)setUpAndConfigure:(NSDictionary*)data bridge:(RCTBridge*)bridge indexPath:(NSIndexPath*)indexPath reactModule:(NSString*)reactModule tableViewTag:(NSNumber*)reactTag { 31 | NSDictionary *props = [self toProps:data indexPath:indexPath reactTag:reactTag]; 32 | if (_rootView == nil) { 33 | //Create the mini react app that will populate our cell. This will be called from cellForRowAtIndexPath 34 | _rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:reactModule initialProperties:props]; 35 | [self.contentView addSubview:_rootView]; 36 | _rootView.frame = self.contentView.frame; 37 | _rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight; 38 | } else { 39 | //Ask react to re-render us with new data 40 | _rootView.appProperties = props; 41 | } 42 | //The application will be unmounted in javascript when the cell/rootview is destroyed 43 | } 44 | 45 | -(void)prepareForReuse { 46 | [super prepareForReuse]; 47 | //TODO prevent stale data flickering 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /RNTableView/RNTableFooterView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableFooterView.h 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTableFooterView : UIView 12 | 13 | @property (nonatomic) float componentHeight; 14 | @property (nonatomic) float componentWidth; 15 | @property (nonatomic, weak) UITableView *tableView; 16 | @end 17 | -------------------------------------------------------------------------------- /RNTableView/RNTableFooterView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableFooterView.m 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableFooterView.h" 10 | 11 | @implementation RNTableFooterView 12 | 13 | 14 | -(void)setComponentHeight:(float)componentHeight { 15 | _componentHeight = componentHeight; 16 | if (componentHeight){ 17 | _tableView.tableFooterView = self; 18 | } 19 | } 20 | 21 | -(void)setComponentWidth:(float)componentWidth { 22 | _componentWidth = componentWidth; 23 | if (componentWidth){ 24 | _tableView.tableFooterView = self; 25 | } 26 | } 27 | 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /RNTableView/RNTableFooterViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableFooterViewManager.h 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTableFooterViewManager : RCTViewManager 12 | 13 | @property (nonatomic) float componentHeight; 14 | @property (nonatomic) float componentWidth; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /RNTableView/RNTableFooterViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableFooterViewManager.m 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableFooterViewManager.h" 10 | #import "RNTableFooterView.h" 11 | #import 12 | 13 | @implementation RNTableFooterViewManager 14 | 15 | RCT_EXPORT_MODULE() 16 | - (UIView *)view 17 | { 18 | return [[RNTableFooterView alloc] init]; 19 | } 20 | 21 | RCT_EXPORT_VIEW_PROPERTY(componentHeight, float) 22 | RCT_EXPORT_VIEW_PROPERTY(componentWidth, float) 23 | @end 24 | -------------------------------------------------------------------------------- /RNTableView/RNTableHeaderView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableHeaderView.h 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTableHeaderView : UIView 12 | 13 | @property (nonatomic) float componentHeight; 14 | @property (nonatomic) float componentWidth; 15 | @property (nonatomic, weak) UITableView *tableView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /RNTableView/RNTableHeaderView.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableHeaderView.m 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableHeaderView.h" 10 | 11 | @implementation RNTableHeaderView 12 | 13 | -(void)setComponentHeight:(float)componentHeight { 14 | _componentHeight = componentHeight; 15 | if (componentHeight){ 16 | _tableView.tableHeaderView = self; 17 | } 18 | } 19 | 20 | -(void)setComponentWidth:(float)componentWidth { 21 | _componentWidth = componentWidth; 22 | if (componentWidth){ 23 | _tableView.tableHeaderView = self; 24 | } 25 | } 26 | 27 | /* 28 | // Only override drawRect: if you perform custom drawing. 29 | // An empty implementation adversely affects performance during animation. 30 | - (void)drawRect:(CGRect)rect { 31 | // Drawing code 32 | } 33 | */ 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /RNTableView/RNTableHeaderViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableHeaderViewManager.h 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTableHeaderViewManager : RCTViewManager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RNTableView/RNTableHeaderViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTableHeaderViewManager.m 3 | // RNTableView 4 | // 5 | // Created by Pavlo Aksonov on 09.11.15. 6 | // Copyright © 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableHeaderViewManager.h" 10 | #import "RNTableHeaderView.h" 11 | @implementation RNTableHeaderViewManager 12 | 13 | RCT_EXPORT_MODULE() 14 | - (UIView *)view 15 | { 16 | return [[RNTableHeaderView alloc] init]; 17 | } 18 | 19 | RCT_EXPORT_VIEW_PROPERTY(componentHeight, float) 20 | RCT_EXPORT_VIEW_PROPERTY(componentWidth, float) 21 | @end 22 | -------------------------------------------------------------------------------- /RNTableView/RNTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SVGUse.h 3 | // SVGReact 4 | // 5 | // Created by Pavlo Aksonov on 07.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class RCTBridge; 13 | 14 | @protocol RNTableViewDatasource 15 | 16 | // create method with params dictionary 17 | - (id)initWithDictionary:(NSDictionary *)params; 18 | 19 | // array of NSDictionary objects (sections) passed to RCTTableViewDatasource (each section should contain "items" value as NSArray of inner items (NSDictionary) 20 | - (NSArray *)sections; 21 | 22 | @end 23 | 24 | @interface RNTableView : UIView 25 | 26 | - (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; 27 | 28 | @property(nonatomic, copy) NSMutableArray *sections; 29 | @property(nonatomic, copy) NSArray *additionalItems; 30 | @property(nonatomic, strong) NSString *json; 31 | @property(nonatomic, strong) NSString *filter; 32 | @property(nonatomic, strong) NSArray *filterArgs; 33 | @property(nonatomic, strong) id selectedValue; 34 | @property(nonatomic) float cellHeight; 35 | @property(nonatomic) float footerHeight; 36 | @property(nonatomic) float headerHeight; 37 | @property(nonatomic) BOOL customCells; 38 | @property(nonatomic) BOOL editing; 39 | @property(nonatomic) BOOL moveWithinSectionOnly; 40 | @property(nonatomic) BOOL allowsSelectionDuringEditing; 41 | @property(nonatomic, assign) UIEdgeInsets contentInset; 42 | @property(nonatomic, assign) CGPoint contentOffset; 43 | @property(nonatomic, assign) UIEdgeInsets scrollIndicatorInsets; 44 | @property(nonatomic, assign) BOOL showsHorizontalScrollIndicator; 45 | @property(nonatomic, assign) BOOL showsVerticalScrollIndicator; 46 | @property(nonatomic, assign) UIEdgeInsets cellSeparatorInset; 47 | @property(nonatomic, assign) BOOL hasCellSeparatorInset; 48 | @property(nonatomic, assign) UIEdgeInsets cellLayoutMargins; 49 | @property(nonatomic, assign) BOOL hasCellLayoutMargins; 50 | @property(nonatomic, assign) BOOL canRefresh; 51 | @property(nonatomic, assign) BOOL refreshing; 52 | 53 | @property(nonatomic, assign) UITableViewStyle tableViewStyle; 54 | @property(nonatomic, assign) UITableViewCellStyle tableViewCellStyle; 55 | @property(nonatomic, assign) UITableViewCellEditingStyle tableViewCellEditingStyle; 56 | @property(nonatomic, assign) UITableViewCellSeparatorStyle separatorStyle; 57 | @property(nonatomic, assign) UITableViewCellAccessoryType accessoryType; 58 | @property(nonatomic, assign) UITableViewCellAccessoryType selectedAccessoryType; 59 | @property(nonatomic, strong) UIFont *font; 60 | @property(nonatomic, strong) UIFont *detailFont; 61 | @property(nonatomic, strong) UIFont *headerFont; 62 | @property(nonatomic, strong) UIColor *headerTextColor; 63 | @property(nonatomic, strong) UIColor *headerBackgroundColor; 64 | @property(nonatomic, strong) UIFont *footerFont; 65 | @property(nonatomic, strong) UIColor *footerTextColor; 66 | 67 | @property(nonatomic, strong) UIColor *textColor; 68 | @property(nonatomic, strong) UIColor *tintColor; 69 | @property(nonatomic, strong) UIColor *selectedTextColor; 70 | @property(nonatomic, strong) UIColor *selectedBackgroundColor; 71 | @property(nonatomic, strong) UIColor *detailTextColor; 72 | @property(nonatomic, strong) UIColor *separatorColor; 73 | @property(nonatomic) BOOL autoFocus; 74 | @property(nonatomic) BOOL autoFocusAnimate; 75 | @property(nonatomic) BOOL allowsToggle; 76 | @property(nonatomic) BOOL allowsMultipleSelection; 77 | @property(nonatomic) BOOL alwaysBounceVertical; 78 | @property(nonatomic) NSString *reactModuleForCell; 79 | 80 | @property(nonatomic, assign) BOOL scrollEnabled; 81 | @property(nonatomic, assign) BOOL sectionIndexTitlesEnabled; 82 | 83 | @property(nonatomic, copy) RCTBubblingEventBlock onWillDisplayCell; 84 | @property(nonatomic, copy) RCTBubblingEventBlock onEndDisplayingCell; 85 | @property(nonatomic, copy) RCTBubblingEventBlock onPress; 86 | @property(nonatomic, copy) RCTBubblingEventBlock onAccessoryPress; 87 | @property(nonatomic, copy) RCTBubblingEventBlock onChange; 88 | @property(nonatomic, copy) RCTDirectEventBlock onScroll; 89 | @property(nonatomic, copy) RCTDirectEventBlock onRefresh; 90 | 91 | - (void)addRefresh; 92 | - (void)stopRefreshing; 93 | - (void)startRefreshing; 94 | - (void)scrollToOffsetX:(CGFloat)x offsetY:(CGFloat)y animated:(BOOL)animated; 95 | - (void)scrollToIndex:(NSInteger)index section:(NSInteger)section animated:(BOOL)animated; 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /RNTableView/RNTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTTableViewCell.h 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RNCellView.h" 11 | @class RNCellView; 12 | 13 | @interface RNTableViewCell : UITableViewCell 14 | 15 | @property (nonatomic, weak) RNCellView *cellView; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /RNTableView/RNTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTTableViewCell.m 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 24.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableViewCell.h" 10 | 11 | @implementation RNTableViewCell 12 | 13 | -(void)setCellView:(RNCellView *)cellView { 14 | _cellView = cellView; 15 | [self.contentView addSubview:cellView]; 16 | } 17 | 18 | -(void)setFrame:(CGRect)frame { 19 | [super setFrame:frame]; 20 | [_cellView setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /RNTableView/RNTableViewManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RCTTableViewManager.h 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 18.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTableViewManager : RCTViewManager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RNTableView/RNTableViewManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RCTTableViewManager.m 3 | // RCTTableView 4 | // 5 | // Created by Pavlo Aksonov on 18.08.15. 6 | // Copyright (c) 2015 Pavlo Aksonov. All rights reserved. 7 | // 8 | 9 | #import "RNTableViewManager.h" 10 | #import "RNTableView.h" 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | 17 | @implementation RNTableViewManager 18 | 19 | RCT_EXPORT_MODULE() 20 | - (UIView *)view 21 | { 22 | return [[RNTableView alloc] initWithBridge:self.bridge]; 23 | } 24 | 25 | + (BOOL)requiresMainQueueSetup 26 | { 27 | return YES; 28 | } 29 | 30 | - (NSArray *)customDirectEventTypes 31 | { 32 | return @[ 33 | @"onWillDisplayCell", 34 | @"onEndDisplayingCell", 35 | @"onItemNotification", 36 | @"onAccessoryPress" 37 | ]; 38 | } 39 | 40 | RCT_EXPORT_VIEW_PROPERTY(sections, NSArray) 41 | RCT_EXPORT_VIEW_PROPERTY(json, NSString) 42 | RCT_EXPORT_VIEW_PROPERTY(editing, BOOL) 43 | RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL) 44 | RCT_EXPORT_VIEW_PROPERTY(autoFocusAnimate, BOOL) 45 | RCT_EXPORT_VIEW_PROPERTY(filter, NSString) 46 | RCT_EXPORT_VIEW_PROPERTY(selectedValue, id) 47 | RCT_EXPORT_VIEW_PROPERTY(filterArgs, NSArray) 48 | RCT_EXPORT_VIEW_PROPERTY(additionalItems, NSArray) 49 | RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) 50 | RCT_EXPORT_VIEW_PROPERTY(selectedSection, NSInteger) 51 | RCT_EXPORT_VIEW_PROPERTY(selectedOrigin, CGPoint) 52 | RCT_EXPORT_VIEW_PROPERTY(cellHeight, float) 53 | RCT_EXPORT_VIEW_PROPERTY(footerHeight, float) 54 | RCT_EXPORT_VIEW_PROPERTY(headerHeight, float) 55 | RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor) 56 | RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) 57 | RCT_EXPORT_VIEW_PROPERTY(selectedTextColor, UIColor) 58 | RCT_EXPORT_VIEW_PROPERTY(selectedBackgroundColor, UIColor) 59 | RCT_EXPORT_VIEW_PROPERTY(detailTextColor, UIColor) 60 | RCT_EXPORT_VIEW_PROPERTY(headerTextColor, UIColor) 61 | RCT_EXPORT_VIEW_PROPERTY(headerBackgroundColor, UIColor) 62 | RCT_EXPORT_VIEW_PROPERTY(footerTextColor, UIColor) 63 | RCT_EXPORT_VIEW_PROPERTY(separatorColor, UIColor) 64 | RCT_EXPORT_VIEW_PROPERTY(moveWithinSectionOnly, BOOL) 65 | RCT_EXPORT_VIEW_PROPERTY(allowsToggle, BOOL) 66 | RCT_EXPORT_VIEW_PROPERTY(allowsMultipleSelection, BOOL) 67 | RCT_EXPORT_VIEW_PROPERTY(alwaysBounceVertical, BOOL) 68 | 69 | RCT_EXPORT_VIEW_PROPERTY(onEndDisplayingCell, RCTBubblingEventBlock) 70 | RCT_EXPORT_VIEW_PROPERTY(onWillDisplayCell, RCTBubblingEventBlock) 71 | RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock) 72 | RCT_EXPORT_VIEW_PROPERTY(onAccessoryPress, RCTBubblingEventBlock) 73 | RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock) 74 | RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock) 75 | RCT_EXPORT_VIEW_PROPERTY(onRefresh, RCTDirectEventBlock) 76 | 77 | RCT_CUSTOM_VIEW_PROPERTY(refreshing, BOOL, RNTableView) { 78 | view.refreshing = [RCTConvert BOOL:json]; 79 | } 80 | 81 | RCT_CUSTOM_VIEW_PROPERTY(canRefresh, BOOL, RNTableView) { 82 | if([RCTConvert BOOL:json]) { 83 | [view addRefresh]; 84 | } 85 | } 86 | 87 | RCT_CUSTOM_VIEW_PROPERTY(tableViewStyle, UITableViewStyle, RNTableView) { 88 | [view setTableViewStyle:[RCTConvert NSInteger:json]]; 89 | } 90 | 91 | RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNTableView) { 92 | [view setScrollEnabled:[RCTConvert BOOL:json]]; 93 | } 94 | 95 | RCT_CUSTOM_VIEW_PROPERTY(sectionIndexTitlesEnabled, BOOL, RNTableView) { 96 | [view setSectionIndexTitlesEnabled:[RCTConvert BOOL:json]]; 97 | } 98 | 99 | RCT_EXPORT_VIEW_PROPERTY(cellForRowAtIndexPath, NSArray) 100 | 101 | RCT_CUSTOM_VIEW_PROPERTY(tableViewCellStyle, UITableViewStyle, RNTableView) { 102 | [view setTableViewCellStyle:[RCTConvert NSInteger:json]]; 103 | } 104 | 105 | RCT_CUSTOM_VIEW_PROPERTY(tableViewCellEditingStyle, UITableViewCellEditingStyle, RNTableView) { 106 | [view setTableViewCellEditingStyle:[RCTConvert NSInteger:json]]; 107 | } 108 | 109 | /*Each cell is a separate app, multiple cells share the app/module name*/ 110 | RCT_CUSTOM_VIEW_PROPERTY(reactModuleForCell, NSString*, RNTableView) { 111 | [view setReactModuleForCell:[RCTConvert NSString:json]]; 112 | } 113 | 114 | RCT_CUSTOM_VIEW_PROPERTY(contentInset, UIEdgeInsets, RNTableView) { 115 | [view setContentInset:[RCTConvert UIEdgeInsets:json]]; 116 | } 117 | 118 | RCT_CUSTOM_VIEW_PROPERTY(separatorStyle, UITableViewCellSeparatorStyle, RNTableView) { 119 | [view setSeparatorStyle:[RCTConvert NSInteger:json]]; 120 | } 121 | 122 | RCT_CUSTOM_VIEW_PROPERTY(contentOffset, CGPoint, RNTableView) { 123 | [view setContentOffset:[RCTConvert CGPoint:json]]; 124 | } 125 | 126 | RCT_CUSTOM_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets, RNTableView) { 127 | [view setScrollIndicatorInsets:[RCTConvert UIEdgeInsets:json]]; 128 | } 129 | 130 | RCT_CUSTOM_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL, RNTableView) { 131 | [view setShowsHorizontalScrollIndicator:[RCTConvert BOOL:json]]; 132 | } 133 | 134 | RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNTableView) { 135 | [view setShowsVerticalScrollIndicator:[RCTConvert BOOL:json]]; 136 | } 137 | 138 | RCT_CUSTOM_VIEW_PROPERTY(cellSeparatorInset, UIEdgeInsets, RNTableView) { 139 | view.hasCellSeparatorInset = YES; 140 | view.cellSeparatorInset = [RCTConvert UIEdgeInsets:json]; 141 | } 142 | 143 | RCT_CUSTOM_VIEW_PROPERTY(cellLayoutMargins, UIEdgeInsets, RNTableView) { 144 | view.hasCellLayoutMargins = YES; 145 | view.cellLayoutMargins = [RCTConvert UIEdgeInsets:json]; 146 | } 147 | 148 | - (NSDictionary *)constantsToExport { 149 | return @{ 150 | @"Constants": @{ 151 | @"Style": @{ 152 | @"Plain": @(UITableViewStylePlain), 153 | @"Grouped": @(UITableViewStyleGrouped) 154 | }, 155 | @"CellStyle": @{ 156 | @"Default": @(UITableViewCellStyleDefault), 157 | @"Value1": @(UITableViewCellStyleValue1), 158 | @"Value2": @(UITableViewCellStyleValue2), 159 | @"Subtitle": @(UITableViewCellStyleSubtitle) 160 | }, 161 | @"CellEditingStyle": @{ 162 | @"None": @(UITableViewCellEditingStyleNone), 163 | @"Delete": @(UITableViewCellEditingStyleDelete), 164 | @"Insert": @(UITableViewCellEditingStyleInsert) 165 | }, 166 | @"CellSelectionStyle": @{ 167 | @"None": @(UITableViewCellSelectionStyleNone), 168 | @"Blue": @(UITableViewCellSelectionStyleBlue), 169 | @"Gray": @(UITableViewCellSelectionStyleGray), 170 | @"Default": @(UITableViewCellSelectionStyleDefault) 171 | }, 172 | @"SeparatorStyle": @{ 173 | @"None": @(UITableViewCellSeparatorStyleNone), 174 | @"Line": @(UITableViewCellSeparatorStyleSingleLine) 175 | }, 176 | @"AccessoryType": @{ 177 | @"None": @(UITableViewCellAccessoryNone), 178 | @"DisclosureIndicator": @(UITableViewCellAccessoryDisclosureIndicator), 179 | @"DisclosureButton": @(UITableViewCellAccessoryDetailDisclosureButton), 180 | @"Checkmark": @(UITableViewCellAccessoryCheckmark), 181 | @"DetailButton": @(UITableViewCellAccessoryDetailButton) 182 | } 183 | } 184 | }; 185 | } 186 | 187 | RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RNTableView) 188 | { 189 | view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)]; 190 | } 191 | RCT_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, RNTableView) 192 | { 193 | view.font = [RCTFont updateFont:view.font withWeight:json]; // defaults to normal 194 | } 195 | RCT_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, RNTableView) 196 | { 197 | view.font = [RCTFont updateFont:view.font withStyle:json]; // defaults to normal 198 | } 199 | RCT_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, RNTableView) 200 | { 201 | view.font = [RCTFont updateFont:view.font withFamily:json ?: defaultView.font.familyName]; 202 | } 203 | 204 | RCT_CUSTOM_VIEW_PROPERTY(detailFontSize, CGFloat, RNTableView) 205 | { 206 | view.detailFont = [RCTFont updateFont:view.detailFont withSize:json ?: @(defaultView.font.pointSize)]; 207 | } 208 | RCT_CUSTOM_VIEW_PROPERTY(detailFontWeight, NSString, RNTableView) 209 | { 210 | view.detailFont = [RCTFont updateFont:view.detailFont withWeight:json]; // defaults to normal 211 | } 212 | RCT_CUSTOM_VIEW_PROPERTY(detailFontStyle, NSString, RNTableView) 213 | { 214 | view.detailFont = [RCTFont updateFont:view.detailFont withStyle:json]; // defaults to normal 215 | } 216 | RCT_CUSTOM_VIEW_PROPERTY(detailFontFamily, NSString, RNTableView) 217 | { 218 | view.detailFont = [RCTFont updateFont:view.detailFont withFamily:json ?: defaultView.font.familyName]; 219 | } 220 | 221 | RCT_CUSTOM_VIEW_PROPERTY(headerFontSize, CGFloat, RNTableView) 222 | { 223 | view.headerFont = [RCTFont updateFont:view.headerFont withSize:json ?: @(defaultView.font.pointSize)]; 224 | } 225 | RCT_CUSTOM_VIEW_PROPERTY(headerFontWeight, NSString, RNTableView) 226 | { 227 | view.headerFont = [RCTFont updateFont:view.headerFont withWeight:json]; // defaults to normal 228 | } 229 | RCT_CUSTOM_VIEW_PROPERTY(headerFontStyle, NSString, RNTableView) 230 | { 231 | view.headerFont = [RCTFont updateFont:view.headerFont withStyle:json]; // defaults to normal 232 | } 233 | RCT_CUSTOM_VIEW_PROPERTY(headerFontFamily, NSString, RNTableView) 234 | { 235 | view.headerFont = [RCTFont updateFont:view.headerFont withFamily:json ?: defaultView.font.familyName]; 236 | } 237 | 238 | RCT_CUSTOM_VIEW_PROPERTY(footerFontSize, CGFloat, RNTableView) 239 | { 240 | view.footerFont = [RCTFont updateFont:view.footerFont withSize:json ?: @(defaultView.font.pointSize)]; 241 | } 242 | RCT_CUSTOM_VIEW_PROPERTY(footerFontWeight, NSString, RNTableView) 243 | { 244 | view.footerFont = [RCTFont updateFont:view.footerFont withWeight:json]; // defaults to normal 245 | } 246 | RCT_CUSTOM_VIEW_PROPERTY(footerFontStyle, NSString, RNTableView) 247 | { 248 | view.footerFont = [RCTFont updateFont:view.footerFont withStyle:json]; // defaults to normal 249 | } 250 | RCT_CUSTOM_VIEW_PROPERTY(footerFontFamily, NSString, RNTableView) 251 | { 252 | view.footerFont = [RCTFont updateFont:view.footerFont withFamily:json ?: defaultView.font.familyName]; 253 | } 254 | 255 | RCT_EXPORT_METHOD(sendNotification:(NSDictionary *)data) 256 | { 257 | RCTComponentEvent *event = [[RCTComponentEvent alloc] initWithName:@"onItemNotification" 258 | viewTag:nil 259 | body:data]; 260 | [self.bridge.eventDispatcher sendEvent:event]; 261 | } 262 | 263 | RCT_EXPORT_METHOD(scrollTo:(nonnull NSNumber *)reactTag 264 | offsetX:(CGFloat)x 265 | offsetY:(CGFloat)y 266 | animated:(BOOL)animated) 267 | { 268 | [self.bridge.uiManager addUIBlock: 269 | ^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry){ 270 | RNTableView *view = viewRegistry[reactTag]; 271 | if (![view isKindOfClass:[RNTableView class]]) { 272 | RCTLogError(@"Invalid view returned from registry, expecting RNTableView, got: %@", view); 273 | } 274 | [view scrollToOffsetX:x offsetY:y animated:true]; 275 | }]; 276 | } 277 | 278 | RCT_EXPORT_METHOD(startRefreshing:(nonnull NSNumber *)reactTag) 279 | { 280 | [self.bridge.uiManager addUIBlock: 281 | ^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry){ 282 | RNTableView *tableView = viewRegistry[reactTag]; 283 | 284 | if ([tableView isKindOfClass:[RNTableView class]]) { 285 | [tableView startRefreshing]; 286 | } else { 287 | RCTLogError(@"Cannot startRefreshing: %@ (tag #%@) is not RNTableView", tableView, reactTag); 288 | } 289 | }]; 290 | } 291 | 292 | RCT_EXPORT_METHOD(stopRefreshing:(nonnull NSNumber *)reactTag) 293 | { 294 | [self.bridge.uiManager addUIBlock: 295 | ^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry){ 296 | RNTableView *tableView = viewRegistry[reactTag]; 297 | 298 | if ([tableView isKindOfClass:[RNTableView class]]) { 299 | [tableView stopRefreshing]; 300 | } else { 301 | RCTLogError(@"Cannot stopRefreshing: %@ (tag #%@) is not RNTableView", tableView, reactTag); 302 | } 303 | }]; 304 | } 305 | 306 | RCT_EXPORT_METHOD(scrollToIndex:(nonnull NSNumber *)reactTag 307 | index:(NSInteger)index 308 | section:(NSInteger)section 309 | animated:(BOOL)animated) 310 | { 311 | [self.bridge.uiManager addUIBlock: 312 | ^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry){ 313 | RNTableView *tableView = viewRegistry[reactTag]; 314 | 315 | if ([tableView isKindOfClass:[RNTableView class]]) { 316 | [tableView scrollToIndex:index section:section animated:animated]; 317 | } else { 318 | RCTLogError(@"Cannot scrollToIndex: %@ (tag #%@) is not RNTableView", tableView, reactTag); 319 | } 320 | }]; 321 | } 322 | @end 323 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | node_modules/react-native/Libraries/react-native/React.js 15 | 16 | ; Ignore polyfills 17 | node_modules/react-native/Libraries/polyfills/.* 18 | 19 | ; These should not be required directly 20 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 21 | node_modules/warning/.* 22 | 23 | ; Flow doesn't support platforms 24 | .*/Libraries/Utilities/HMRLoadingView.js 25 | 26 | [untyped] 27 | .*/node_modules/@react-native-community/cli/.*/.* 28 | 29 | [include] 30 | 31 | [libs] 32 | node_modules/react-native/Libraries/react-native/react-native-interface.js 33 | node_modules/react-native/flow/ 34 | 35 | [options] 36 | emoji=true 37 | 38 | esproposal.optional_chaining=enable 39 | esproposal.nullish_coalescing=enable 40 | 41 | module.file_ext=.js 42 | module.file_ext=.json 43 | module.file_ext=.ios.js 44 | 45 | module.system=haste 46 | module.system.haste.use_name_reducers=true 47 | # get basename 48 | module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' 49 | # strip .js or .js.flow suffix 50 | module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' 51 | # strip .ios suffix 52 | module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' 53 | module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' 54 | module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' 55 | module.system.haste.paths.blacklist=.*/__tests__/.* 56 | module.system.haste.paths.blacklist=.*/__mocks__/.* 57 | module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* 58 | module.system.haste.paths.whitelist=/node_modules/react-native/RNTester/.* 59 | module.system.haste.paths.whitelist=/node_modules/react-native/IntegrationTests/.* 60 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/react-native/react-native-implementation.js 61 | module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* 62 | 63 | munge_underscores=true 64 | 65 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 66 | 67 | suppress_type=$FlowIssue 68 | suppress_type=$FlowFixMe 69 | suppress_type=$FlowFixMeProps 70 | suppress_type=$FlowFixMeState 71 | 72 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 73 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 74 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 75 | 76 | [lints] 77 | sketchy-null-number=warn 78 | sketchy-null-mixed=warn 79 | sketchy-number=warn 80 | untyped-type-import=warn 81 | nonstrict-import=warn 82 | deprecated-type=warn 83 | unsafe-getters-setters=warn 84 | inexact-spread=warn 85 | unnecessary-invariant=warn 86 | signature-verification-failure=warn 87 | deprecated-utility=error 88 | 89 | [strict] 90 | deprecated-type 91 | nonstrict-import 92 | sketchy-null 93 | unclear-type 94 | unsafe-getters-setters 95 | untyped-import 96 | untyped-type-import 97 | 98 | [version] 99 | ^0.98.0 100 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /example/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.tableviewdemo", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.tableviewdemo", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format 22 | * bundleCommand: "ram-bundle", 23 | * 24 | * // whether to bundle JS and assets in debug mode 25 | * bundleInDebug: false, 26 | * 27 | * // whether to bundle JS and assets in release mode 28 | * bundleInRelease: true, 29 | * 30 | * // whether to bundle JS and assets in another build variant (if configured). 31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 32 | * // The configuration property can be in the following formats 33 | * // 'bundleIn${productFlavor}${buildType}' 34 | * // 'bundleIn${buildType}' 35 | * // bundleInFreeDebug: true, 36 | * // bundleInPaidRelease: true, 37 | * // bundleInBeta: true, 38 | * 39 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 40 | * // for example: to disable dev mode in the staging build type (if configured) 41 | * devDisabledInStaging: true, 42 | * // The configuration property can be in the following formats 43 | * // 'devDisabledIn${productFlavor}${buildType}' 44 | * // 'devDisabledIn${buildType}' 45 | * 46 | * // the root of your project, i.e. where "package.json" lives 47 | * root: "../../", 48 | * 49 | * // where to put the JS bundle asset in debug mode 50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 51 | * 52 | * // where to put the JS bundle asset in release mode 53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 54 | * 55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 56 | * // require('./image.png')), in debug mode 57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 58 | * 59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 60 | * // require('./image.png')), in release mode 61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 62 | * 63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 67 | * // for example, you might want to remove it from here. 68 | * inputExcludes: ["android/**", "ios/**"], 69 | * 70 | * // override which node gets called and with what additional arguments 71 | * nodeExecutableAndArgs: ["node"], 72 | * 73 | * // supply additional arguments to the packager 74 | * extraPackagerArgs: [] 75 | * ] 76 | */ 77 | 78 | project.ext.react = [ 79 | entryFile: "index.js", 80 | enableHermes: false, // clean and rebuild if changing 81 | ] 82 | 83 | apply from: "../../node_modules/react-native/react.gradle" 84 | 85 | /** 86 | * Set this to true to create two separate APKs instead of one: 87 | * - An APK that only works on ARM devices 88 | * - An APK that only works on x86 devices 89 | * The advantage is the size of the APK is reduced by about 4MB. 90 | * Upload all the APKs to the Play Store and people will download 91 | * the correct one based on the CPU architecture of their device. 92 | */ 93 | def enableSeparateBuildPerCPUArchitecture = false 94 | 95 | /** 96 | * Run Proguard to shrink the Java bytecode in release builds. 97 | */ 98 | def enableProguardInReleaseBuilds = false 99 | 100 | /** 101 | * The preferred build flavor of JavaScriptCore. 102 | * 103 | * For example, to use the international variant, you can use: 104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 105 | * 106 | * The international variant includes ICU i18n library and necessary data 107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 108 | * give correct results when using with locales other than en-US. Note that 109 | * this variant is about 6MiB larger per architecture than default. 110 | */ 111 | def jscFlavor = 'org.webkit:android-jsc:+' 112 | 113 | /** 114 | * Whether to enable the Hermes VM. 115 | * 116 | * This should be set on project.ext.react and mirrored here. If it is not set 117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 118 | * and the benefits of using Hermes will therefore be sharply reduced. 119 | */ 120 | def enableHermes = project.ext.react.get("enableHermes", false); 121 | 122 | android { 123 | compileSdkVersion rootProject.ext.compileSdkVersion 124 | 125 | compileOptions { 126 | sourceCompatibility JavaVersion.VERSION_1_8 127 | targetCompatibility JavaVersion.VERSION_1_8 128 | } 129 | 130 | defaultConfig { 131 | applicationId "com.tableviewdemo" 132 | minSdkVersion rootProject.ext.minSdkVersion 133 | targetSdkVersion rootProject.ext.targetSdkVersion 134 | versionCode 1 135 | versionName "1.0" 136 | } 137 | splits { 138 | abi { 139 | reset() 140 | enable enableSeparateBuildPerCPUArchitecture 141 | universalApk false // If true, also generate a universal APK 142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 143 | } 144 | } 145 | signingConfigs { 146 | debug { 147 | storeFile file('debug.keystore') 148 | storePassword 'android' 149 | keyAlias 'androiddebugkey' 150 | keyPassword 'android' 151 | } 152 | } 153 | buildTypes { 154 | debug { 155 | signingConfig signingConfigs.debug 156 | } 157 | release { 158 | // Caution! In production, you need to generate your own keystore file. 159 | // see https://facebook.github.io/react-native/docs/signed-apk-android. 160 | signingConfig signingConfigs.debug 161 | minifyEnabled enableProguardInReleaseBuilds 162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 163 | } 164 | } 165 | // applicationVariants are e.g. debug, release 166 | applicationVariants.all { variant -> 167 | variant.outputs.each { output -> 168 | // For each separate APK per architecture, set a unique version code as described here: 169 | // https://developer.android.com/studio/build/configure-apk-splits.html 170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 171 | def abi = output.getFilter(OutputFile.ABI) 172 | if (abi != null) { // null for the universal-debug, universal-release variants 173 | output.versionCodeOverride = 174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 175 | } 176 | 177 | } 178 | } 179 | 180 | packagingOptions { 181 | pickFirst '**/armeabi-v7a/libc++_shared.so' 182 | pickFirst '**/x86/libc++_shared.so' 183 | pickFirst '**/arm64-v8a/libc++_shared.so' 184 | pickFirst '**/x86_64/libc++_shared.so' 185 | pickFirst '**/x86/libjsc.so' 186 | pickFirst '**/armeabi-v7a/libjsc.so' 187 | } 188 | } 189 | 190 | dependencies { 191 | implementation fileTree(dir: "libs", include: ["*.jar"]) 192 | implementation "com.facebook.react:react-native:+" // From node_modules 193 | 194 | if (enableHermes) { 195 | def hermesPath = "../../node_modules/hermesvm/android/"; 196 | debugImplementation files(hermesPath + "hermes-debug.aar") 197 | releaseImplementation files(hermesPath + "hermes-release.aar") 198 | } else { 199 | implementation jscFlavor 200 | } 201 | } 202 | 203 | // Run this once to be able to run the application with BUCK 204 | // puts all compile dependencies into folder libs for BUCK to use 205 | task copyDownloadableDepsToLibs(type: Copy) { 206 | from configurations.compile 207 | into 'libs' 208 | } 209 | 210 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 211 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/tableviewdemo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tableviewdemo; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "TableViewDemo"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/tableviewdemo/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.tableviewdemo; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.PackageList; 7 | import com.facebook.hermes.reactexecutor.HermesExecutorFactory; 8 | import com.facebook.react.bridge.JavaScriptExecutorFactory; 9 | import com.facebook.react.ReactApplication; 10 | import com.facebook.react.ReactNativeHost; 11 | import com.facebook.react.ReactPackage; 12 | import com.facebook.soloader.SoLoader; 13 | 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for example: 29 | // packages.add(new MyReactNativePackage()); 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | SoLoader.init(this, /* native exopackage */ false); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TableViewDemo 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "28.0.3" 6 | minSdkVersion = 16 7 | compileSdkVersion = 28 8 | targetSdkVersion = 28 9 | supportLibVersion = "28.0.0" 10 | } 11 | repositories { 12 | google() 13 | jcenter() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:3.4.1") 17 | 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | mavenLocal() 26 | maven { 27 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 28 | url("$rootDir/../node_modules/react-native/android") 29 | } 30 | maven { 31 | // Android JSC is installed from npm 32 | url("$rootDir/../node_modules/jsc-android/dist") 33 | } 34 | 35 | google() 36 | jcenter() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aksonov/react-native-tableview/853abc2a9087d4e2597ee01bef8f57480a8190ce/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'TableViewDemo' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TableViewDemo", 3 | "displayName": "TableViewDemo" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | export { default } from './src'; 2 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '9.0' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | target 'TableViewDemo' do 5 | # Pods for TableViewDemo 6 | pod 'React', :path => '../node_modules/react-native/' 7 | pod 'React-Core', :path => '../node_modules/react-native/React' 8 | pod 'React-DevSupport', :path => '../node_modules/react-native/React' 9 | pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS' 10 | pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation' 11 | pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob' 12 | pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image' 13 | pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS' 14 | pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network' 15 | pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings' 16 | pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text' 17 | pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration' 18 | pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket' 19 | 20 | pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact' 21 | pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi' 22 | pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor' 23 | pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector' 24 | pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga' 25 | 26 | pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' 27 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec' 28 | pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec' 29 | 30 | target 'TableViewDemoTests' do 31 | inherit! :search_paths 32 | # Pods for testing 33 | end 34 | 35 | use_native_modules! 36 | end 37 | 38 | target 'TableViewDemo-tvOS' do 39 | # Pods for TableViewDemo-tvOS 40 | 41 | target 'TableViewDemo-tvOSTests' do 42 | inherit! :search_paths 43 | # Pods for testing 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost-for-react-native (1.63.0) 3 | - DoubleConversion (1.1.6) 4 | - Folly (2018.10.22.00): 5 | - boost-for-react-native 6 | - DoubleConversion 7 | - Folly/Default (= 2018.10.22.00) 8 | - glog 9 | - Folly/Default (2018.10.22.00): 10 | - boost-for-react-native 11 | - DoubleConversion 12 | - glog 13 | - glog (0.3.5) 14 | - React (0.60.5): 15 | - React-Core (= 0.60.5) 16 | - React-DevSupport (= 0.60.5) 17 | - React-RCTActionSheet (= 0.60.5) 18 | - React-RCTAnimation (= 0.60.5) 19 | - React-RCTBlob (= 0.60.5) 20 | - React-RCTImage (= 0.60.5) 21 | - React-RCTLinking (= 0.60.5) 22 | - React-RCTNetwork (= 0.60.5) 23 | - React-RCTSettings (= 0.60.5) 24 | - React-RCTText (= 0.60.5) 25 | - React-RCTVibration (= 0.60.5) 26 | - React-RCTWebSocket (= 0.60.5) 27 | - React-Core (0.60.5): 28 | - Folly (= 2018.10.22.00) 29 | - React-cxxreact (= 0.60.5) 30 | - React-jsiexecutor (= 0.60.5) 31 | - yoga (= 0.60.5.React) 32 | - React-cxxreact (0.60.5): 33 | - boost-for-react-native (= 1.63.0) 34 | - DoubleConversion 35 | - Folly (= 2018.10.22.00) 36 | - glog 37 | - React-jsinspector (= 0.60.5) 38 | - React-DevSupport (0.60.5): 39 | - React-Core (= 0.60.5) 40 | - React-RCTWebSocket (= 0.60.5) 41 | - React-jsi (0.60.5): 42 | - boost-for-react-native (= 1.63.0) 43 | - DoubleConversion 44 | - Folly (= 2018.10.22.00) 45 | - glog 46 | - React-jsi/Default (= 0.60.5) 47 | - React-jsi/Default (0.60.5): 48 | - boost-for-react-native (= 1.63.0) 49 | - DoubleConversion 50 | - Folly (= 2018.10.22.00) 51 | - glog 52 | - React-jsiexecutor (0.60.5): 53 | - DoubleConversion 54 | - Folly (= 2018.10.22.00) 55 | - glog 56 | - React-cxxreact (= 0.60.5) 57 | - React-jsi (= 0.60.5) 58 | - React-jsinspector (0.60.5) 59 | - React-RCTActionSheet (0.60.5): 60 | - React-Core (= 0.60.5) 61 | - React-RCTAnimation (0.60.5): 62 | - React-Core (= 0.60.5) 63 | - React-RCTBlob (0.60.5): 64 | - React-Core (= 0.60.5) 65 | - React-RCTNetwork (= 0.60.5) 66 | - React-RCTWebSocket (= 0.60.5) 67 | - React-RCTImage (0.60.5): 68 | - React-Core (= 0.60.5) 69 | - React-RCTNetwork (= 0.60.5) 70 | - React-RCTLinking (0.60.5): 71 | - React-Core (= 0.60.5) 72 | - React-RCTNetwork (0.60.5): 73 | - React-Core (= 0.60.5) 74 | - React-RCTSettings (0.60.5): 75 | - React-Core (= 0.60.5) 76 | - React-RCTText (0.60.5): 77 | - React-Core (= 0.60.5) 78 | - React-RCTVibration (0.60.5): 79 | - React-Core (= 0.60.5) 80 | - React-RCTWebSocket (0.60.5): 81 | - React-Core (= 0.60.5) 82 | - RNGestureHandler (1.4.1): 83 | - React 84 | - RNReanimated (1.2.0): 85 | - React 86 | - RNTableView (3.0.0): 87 | - React 88 | - yoga (0.60.5.React) 89 | 90 | DEPENDENCIES: 91 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 92 | - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) 93 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 94 | - React (from `../node_modules/react-native/`) 95 | - React-Core (from `../node_modules/react-native/React`) 96 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 97 | - React-DevSupport (from `../node_modules/react-native/React`) 98 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 99 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 100 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 101 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 102 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 103 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 104 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 105 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 106 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 107 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 108 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 109 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 110 | - React-RCTWebSocket (from `../node_modules/react-native/Libraries/WebSocket`) 111 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) 112 | - RNReanimated (from `../node_modules/react-native-reanimated`) 113 | - RNTableView (from `../node_modules/react-native-tableview`) 114 | - yoga (from `../node_modules/react-native/ReactCommon/yoga`) 115 | 116 | SPEC REPOS: 117 | https://github.com/cocoapods/specs.git: 118 | - boost-for-react-native 119 | 120 | EXTERNAL SOURCES: 121 | DoubleConversion: 122 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 123 | Folly: 124 | :podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec" 125 | glog: 126 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 127 | React: 128 | :path: "../node_modules/react-native/" 129 | React-Core: 130 | :path: "../node_modules/react-native/React" 131 | React-cxxreact: 132 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 133 | React-DevSupport: 134 | :path: "../node_modules/react-native/React" 135 | React-jsi: 136 | :path: "../node_modules/react-native/ReactCommon/jsi" 137 | React-jsiexecutor: 138 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 139 | React-jsinspector: 140 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 141 | React-RCTActionSheet: 142 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 143 | React-RCTAnimation: 144 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 145 | React-RCTBlob: 146 | :path: "../node_modules/react-native/Libraries/Blob" 147 | React-RCTImage: 148 | :path: "../node_modules/react-native/Libraries/Image" 149 | React-RCTLinking: 150 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 151 | React-RCTNetwork: 152 | :path: "../node_modules/react-native/Libraries/Network" 153 | React-RCTSettings: 154 | :path: "../node_modules/react-native/Libraries/Settings" 155 | React-RCTText: 156 | :path: "../node_modules/react-native/Libraries/Text" 157 | React-RCTVibration: 158 | :path: "../node_modules/react-native/Libraries/Vibration" 159 | React-RCTWebSocket: 160 | :path: "../node_modules/react-native/Libraries/WebSocket" 161 | RNGestureHandler: 162 | :path: "../node_modules/react-native-gesture-handler" 163 | RNReanimated: 164 | :path: "../node_modules/react-native-reanimated" 165 | RNTableView: 166 | :path: "../node_modules/react-native-tableview" 167 | yoga: 168 | :path: "../node_modules/react-native/ReactCommon/yoga" 169 | 170 | SPEC CHECKSUMS: 171 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c 172 | DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 173 | Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 174 | glog: 1f3da668190260b06b429bb211bfbee5cd790c28 175 | React: 53c53c4d99097af47cf60594b8706b4e3321e722 176 | React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64 177 | React-cxxreact: 8384287780c4999351ad9b6e7a149d9ed10a2395 178 | React-DevSupport: 197fb409737cff2c4f9986e77c220d7452cb9f9f 179 | React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2 180 | React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30 181 | React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4 182 | React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90 183 | React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e 184 | React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24 185 | React-RCTImage: f5f1c50922164e89bdda67bcd0153952a5cfe719 186 | React-RCTLinking: d0ecbd791e9ddddc41fa1f66b0255de90e8ee1e9 187 | React-RCTNetwork: e26946300b0ab7bb6c4a6348090e93fa21f33a9d 188 | React-RCTSettings: d0d37cb521b7470c998595a44f05847777cc3f42 189 | React-RCTText: b074d89033583d4f2eb5faf7ea2db3a13c7553a2 190 | React-RCTVibration: 2105b2e0e2b66a6408fc69a46c8a7fb5b2fdade0 191 | React-RCTWebSocket: cd932a16b7214898b6b7f788c8bddb3637246ac4 192 | RNGestureHandler: 4cb47a93019c1a201df2644413a0a1569a51c8aa 193 | RNReanimated: 1b52415c4302f198cb581282a0166690bad62c43 194 | RNTableView: 410a8e2944841e103d2d9b9cc389400c2fa7c327 195 | yoga: 312528f5bbbba37b4dcea5ef00e8b4033fdd9411 196 | 197 | PODFILE CHECKSUM: 939816b29539e742498e930333f7ff807ff5b982 198 | 199 | COCOAPODS: 1.7.3 200 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo.xcodeproj/xcshareddata/xcschemes/TableViewDemo-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo.xcodeproj/xcshareddata/xcschemes/TableViewDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (nonatomic, strong) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 19 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 20 | moduleName:@"TableViewDemo" 21 | initialProperties:nil]; 22 | 23 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 24 | 25 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 26 | UIViewController *rootViewController = [UIViewController new]; 27 | rootViewController.view = rootView; 28 | self.window.rootViewController = rootViewController; 29 | [self.window makeKeyAndVisible]; 30 | return YES; 31 | } 32 | 33 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 34 | { 35 | #if DEBUG 36 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 37 | #else 38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 39 | #endif 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /example/ios/TableViewDemo/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | TableViewDemo 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | NSExceptionDomains 32 | 33 | localhost 34 | 35 | NSExceptionAllowsInsecureHTTPLoads 36 | 37 | 38 | 39 | 40 | NSLocationWhenInUseUsageDescription 41 | 42 | UILaunchStoryboardName 43 | LaunchScreen 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UIViewControllerBasedStatusBarAppearance 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /example/ios/TableViewDemo/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /example/ios/TableViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/TableViewDemoTests/TableViewDemoTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | #define TIMEOUT_SECONDS 600 15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 16 | 17 | @interface TableViewDemoTests : XCTestCase 18 | 19 | @end 20 | 21 | @implementation TableViewDemoTests 22 | 23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 24 | { 25 | if (test(view)) { 26 | return YES; 27 | } 28 | for (UIView *subview in [view subviews]) { 29 | if ([self findSubviewInView:subview matching:test]) { 30 | return YES; 31 | } 32 | } 33 | return NO; 34 | } 35 | 36 | - (void)testRendersWelcomeScreen 37 | { 38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 40 | BOOL foundElement = NO; 41 | 42 | __block NSString *redboxError = nil; 43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 44 | if (level >= RCTLogLevelError) { 45 | redboxError = message; 46 | } 47 | }); 48 | 49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 52 | 53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 55 | return YES; 56 | } 57 | return NO; 58 | }]; 59 | } 60 | 61 | RCTSetLogFunction(RCTDefaultLogFunction); 62 | 63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 65 | } 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: false, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TableViewDemo", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "react-native start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "prop-types": "^15.7.2", 11 | "react": "16.8.6", 12 | "react-native": "0.60.5", 13 | "react-native-gesture-handler": "^1.4.1", 14 | "react-native-reanimated": "^1.2.0", 15 | "react-native-tableview": "^3.0.0", 16 | "react-navigation": "^3.12.1" 17 | }, 18 | "devDependencies": { 19 | "@babel/core": "^7.5.5", 20 | "@babel/runtime": "^7.5.5", 21 | "babel-jest": "^24.9.0", 22 | "jest": "^24.9.0", 23 | "metro-react-native-babel-preset": "^0.56.0", 24 | "react-test-renderer": "16.8.6" 25 | }, 26 | "jest": { 27 | "preset": "react-native" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example/src/cells/TableViewExampleCell.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | import { View, Text } from 'react-native'; 4 | 5 | const TableViewExampleCell = props => { 6 | const style = { 7 | borderColor: '#aaaaaa', 8 | borderWidth: 1, 9 | borderRadius: 3, 10 | flex: 1, 11 | }; 12 | 13 | if (props.data.backgroundColor !== undefined) { 14 | style.backgroundColor = props.data.backgroundColor; 15 | } 16 | 17 | return ( 18 | 19 | 20 | section:{props.section},row:{props.row},label:{props.data.label} 21 | 22 | 23 | ); 24 | }; 25 | 26 | TableViewExampleCell.propTypes = { 27 | data: PropTypes.object, 28 | section: PropTypes.number, 29 | row: PropTypes.number, 30 | }; 31 | 32 | TableViewExampleCell.defaultProps = { 33 | data: null, 34 | section: null, 35 | row: null, 36 | }; 37 | 38 | export default TableViewExampleCell; 39 | -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import { createStackNavigator, createAppContainer } from 'react-navigation'; 3 | import Home from './screens/Home'; 4 | import Example1 from './screens/Example1'; 5 | import Example2 from './screens/Example2'; 6 | import Example3 from './screens/Example3'; 7 | import Example4 from './screens/Example4'; 8 | import Example5 from './screens/Example5'; 9 | import Example6 from './screens/Example6'; 10 | import Example7 from './screens/Example7'; 11 | import Example8 from './screens/Example8'; 12 | 13 | import TableViewExampleCell from './cells/TableViewExampleCell'; 14 | 15 | const Stack = createStackNavigator( 16 | { 17 | home: { 18 | screen: Home, 19 | navigationOptions: { 20 | title: 'TableView Examples', 21 | }, 22 | }, 23 | sections: { 24 | screen: Example1, 25 | navigationOptions: { 26 | title: 'Multiple Sections', 27 | }, 28 | }, 29 | accessories: { 30 | screen: Example2, 31 | navigationOptions: { 32 | title: 'Accessory Types', 33 | }, 34 | }, 35 | json: { 36 | screen: Example3, 37 | navigationOptions: { 38 | title: 'Bundled JSON', 39 | }, 40 | }, 41 | network: { 42 | screen: Example4, 43 | navigationOptions: { 44 | title: 'Large Network Loaded List', 45 | }, 46 | }, 47 | custom: { 48 | screen: Example5, 49 | navigationOptions: { 50 | title: 'Custom Cells', 51 | }, 52 | }, 53 | edit: { 54 | screen: Example6, 55 | navigationOptions: { 56 | title: 'Editing Mode', 57 | }, 58 | }, 59 | refresh: { 60 | screen: Example7, 61 | navigationOptions: { 62 | title: 'Pull to Refresh', 63 | }, 64 | }, 65 | index: { 66 | screen: Example8, 67 | navigationOptions: { 68 | title: 'Scroll to Index', 69 | }, 70 | }, 71 | }, 72 | { 73 | defaultNavigationOptions: { 74 | headerStyle: { 75 | backgroundColor: '#47A1D7', 76 | }, 77 | headerTintColor: '#fff', 78 | }, 79 | initialRouteName: 'home', 80 | } 81 | ); 82 | 83 | const App = createAppContainer(Stack); 84 | 85 | AppRegistry.registerComponent('TableViewDemo', () => App); 86 | AppRegistry.registerComponent( 87 | 'TableViewExampleCell', 88 | () => TableViewExampleCell 89 | ); 90 | -------------------------------------------------------------------------------- /example/src/screens/Example1.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import TableView from 'react-native-tableview'; 3 | 4 | const { Section, Item } = TableView; 5 | 6 | const Example1 = () => ( 7 | console.log(event)} 14 | > 15 |
16 | 17 | Item 1 18 | 19 | Item 2 20 | Item 3 21 |
22 | 23 |
24 | Item 1 25 | Item 2 26 | Item 3 27 |
28 | 29 |
30 | Item 1 31 | Item 2 32 | Item 3 33 |
34 |
35 | ); 36 | 37 | export default Example1; 38 | -------------------------------------------------------------------------------- /example/src/screens/Example2.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-alert */ 2 | import React from 'react'; 3 | import TableView from 'react-native-tableview'; 4 | 5 | const { Section, Item } = TableView; 6 | const { 7 | DisclosureIndicator, 8 | DisclosureButton, 9 | Checkmark, 10 | DetailButton, 11 | } = TableView.Consts.AccessoryType; 12 | 13 | const Example2 = () => ( 14 | alert(label)} 18 | onAccessoryPress={() => {}} 19 | > 20 |
21 | No accessory 22 | I have an arrow 23 | alert('You Pressed my button')} 26 | > 27 | I have an arrow and a button 28 | 29 | I have a checkmark 30 | alert('You Pressed my button')} 33 | > 34 | I have a button 35 | 36 |
37 |
38 | ); 39 | 40 | export default Example2; 41 | -------------------------------------------------------------------------------- /example/src/screens/Example3.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-alert */ 2 | import React from 'react'; 3 | import { View, Text, StyleSheet } from 'react-native'; 4 | import TableView from 'react-native-tableview'; 5 | 6 | const styles = StyleSheet.create({ 7 | title: { 8 | margin: 20, 9 | color: '#5FA0D2', 10 | fontSize: 20, 11 | textAlign: 'center', 12 | }, 13 | }); 14 | 15 | const Example3 = () => { 16 | // list spanish provinces and add 'All states' item at the beginning 17 | 18 | const country = 'ES'; 19 | 20 | return ( 21 | 22 | Showing States in Spain 23 | alert(JSON.stringify(event))} 30 | /> 31 | 32 | ); 33 | }; 34 | 35 | export default Example3; 36 | -------------------------------------------------------------------------------- /example/src/screens/Example4.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { View, ActivityIndicator, Text, StyleSheet } from 'react-native'; 3 | import TableView from 'react-native-tableview'; 4 | 5 | const { Section, Item } = TableView; 6 | 7 | const styles = StyleSheet.create({ 8 | title: { 9 | margin: 20, 10 | color: '#5FA0D2', 11 | fontSize: 20, 12 | textAlign: 'center', 13 | }, 14 | }); 15 | 16 | const Example4 = () => { 17 | const [loading, setLoading] = useState(true); 18 | const [users, setUsers] = useState([]); 19 | 20 | useEffect(() => { 21 | const getUsers = async () => { 22 | const response = await fetch('https://randomuser.me/api/?results=5000'); 23 | const data = await response.json(); 24 | 25 | setLoading(false); 26 | setUsers( 27 | data.results.map(a => ({ 28 | name: `${a.name.first} ${a.name.last}`, 29 | id: a.registered, 30 | })) 31 | ); 32 | }; 33 | 34 | getUsers(); 35 | }, []); 36 | 37 | return ( 38 | 39 | 40 | {loading ? 'Fetching' : 'Fetched'} 5000 users 41 | 42 | 43 | {loading && } 44 | 45 | 49 |
50 | {users.map(a => ( 51 | {a.name} 52 | ))} 53 |
54 |
55 |
56 | ); 57 | }; 58 | 59 | export default Example4; 60 | -------------------------------------------------------------------------------- /example/src/screens/Example5.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-alert */ 2 | import React from 'react'; 3 | import TableView from 'react-native-tableview'; 4 | 5 | const { Item, Section } = TableView; 6 | 7 | const Example5 = () => ( 8 | // list spanish provinces and add 'All states' item at the beginning 9 | 10 | alert(JSON.stringify(event))} 17 | > 18 |
19 | Item 1 20 | Item 2 21 | Item 3 22 | 23 | Item 4 24 | 25 | Item 5 26 | Item 6 27 | Item 7 28 | Item 8 29 | Item 9 30 | 31 | Item 10 32 | 33 | Item 11 34 | Item 12 35 | Item 13 36 | Item 14 37 | Item 15 38 | Item 16 39 |
40 |
41 | Item 1 42 | Item 2 43 | Item 3 44 |
45 |
46 | Item 1 47 | Item 2 48 | Item 3 49 |
50 |
51 | ); 52 | 53 | export default Example5; 54 | -------------------------------------------------------------------------------- /example/src/screens/Example6.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-alert */ 2 | import React from 'react'; 3 | import PropTypes from 'prop-types'; 4 | import { View, Button } from 'react-native'; 5 | import TableView from 'react-native-tableview'; 6 | 7 | const { Item, Section, Consts } = TableView; 8 | 9 | const Example6 = ({ navigation }) => { 10 | return ( 11 | 12 | alert(JSON.stringify(event))} 16 | onChange={event => alert(`CHANGED:${JSON.stringify(event)}`)} 17 | > 18 |
19 | Item 1 20 | Item 2 21 | Item 3 22 | Item 4 23 |
24 |
25 | alert(JSON.stringify(event))} 30 | onChange={event => alert(`CHANGED:${JSON.stringify(event)}`)} 31 | > 32 |
33 | Item 1 34 | Item 2 35 | Item 3 36 | Item 4 37 |
38 |
39 |
40 | ); 41 | }; 42 | 43 | Example6.navigationOptions = ({ navigation }) => { 44 | const editing = navigation.getParam('editing'); 45 | 46 | return { 47 | headerRight: ( 48 |