Skip to content

Commit

Permalink
fix onPress event for React Native 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov committed Aug 29, 2015
1 parent 81046a1 commit c722d37
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>RCTTableView.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
2 changes: 1 addition & 1 deletion RCTTableView/RCTTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
newValue[@"selectedSection"] = [NSNumber numberWithInteger:indexPath.section];


[_eventDispatcher sendInputEventWithName:@"topTap" body:newValue];
[_eventDispatcher sendInputEventWithName:@"press" body:newValue];
if (oldValue[@"selected"]){
[oldValue removeObjectForKey:@"selected"];
[newValue setObject:@1 forKey:@"selected"];
Expand Down
38 changes: 19 additions & 19 deletions examples/TableViewDemo/.idea/workspace.xml

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

4 changes: 2 additions & 2 deletions examples/TableViewDemo/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var Item = TableView.Item;
var Cell = TableView.Cell;

class TableViewExample extends React.Component {
render(){
render4(){
return (
<TableView style={{flex:1}} onPress={(event) => alert(JSON.stringify(event))} selectedValue="1">
<Section label="section 1">
Expand Down Expand Up @@ -36,7 +36,7 @@ class TableViewExample extends React.Component {
}

// list spanish provinces and add 'All states' item at the beginning
render4(){
render(){
var country = "ES";
return (
<TableView selectedValue="" style={{flex:1}} json="states" filter={`country=='${country}'`}
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var TableView = React.createClass({
},

_onChange: function(event) {
console.log("ONCHANGE");
if (this.props.onPress) {
this.props.onPress(event.nativeEvent);
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-tableview",
"version": "1.1.1",
"version": "1.1.2",
"description": "Native iOS TableView wrapper for React Native",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"readme": "# react-native-tableview\nNative iOS UITableView for React Native with JSON support.\n\n## Why I need to use it?\n- To display long lists of data (like country list) - built-in list view has performance issues for long lists\n- To use built-in accessory types (checkmark or disclosure indicator)\n- Automatic scroll to initial selected value during component initialization\n- Automatic item selection with \"checkmark\" with old item de-selection (optionally), see demo, useful to select country/state/etc.\n- Native JSON support for datasource. If you need to display large dataset, generated Javascript will became very large and impact js loading time. To solve this problem the component could read JSON directly from app bundle without JS!\n- Filter JSON datasources using NSPredicate syntax. For example you could select states for given country only (check demo)\n\n## Supports UITableView styles\n- UITableViewStylePlain (TableView.Consts.Style.Plain)\n- UITableViewStyleGrouped (TableView.Consts.Style.Grouped)\n\n## Supports UITableViewCell styles\n- UITableViewCellStyleDefault (TableView.Consts.CellStyle.Default)\n- UITableViewCellStyleValue1 (TableView.Consts.CellStyle.Value1)\n- UITableViewCellStyleValue2 (TableView.Consts.CellStyle.Value2)\n- UITableViewCellStyleSubtitle (TableView.Consts.CellStyle.Subtitle)\n\n## Supports accessory types\n- UITableViewCellAccessoryDisclosureIndicator (\"arrow\" attribute for TableView.Item or TableView.Section)\n- UITableViewCellAccessoryCheckmark (\"selected\" attribute for TableView.Item)\n\n## Example 1\n![demo](https://cloud.githubusercontent.com/assets/1321329/9329083/cc77b4e0-45ae-11e5-9919-34f12e6d407c.gif)\n\n```\n'use strict';\n\nvar React = require('react-native');\nvar { AppRegistry } = React;\nvar TableView = require('react-native-tableview');\nvar Section = TableView.Section;\nvar Item = TableView.Item;\n\nclass TableViewExample extends React.Component {\n render(){\n return (\n <TableView style={{flex:1}}\n tableViewStyle={TableView.Consts.Style.Grouped}\n tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}\n onPress={(event) => console.log(event)}>\n <Section label=\"Section 1\" arrow={true}>\n <Item value=\"1\" detail=\"Detail1\" >Item 1</Item>\n <Item value=\"2\">Item 2</Item>\n <Item>Item 3</Item>\n <Item>Item 4</Item>\n <Item>Item 5</Item>\n <Item>Item 6</Item>\n <Item>Item 7</Item>\n <Item>Item 8</Item>\n <Item>Item 9</Item>\n <Item>Item 10</Item>\n <Item>Item 11</Item>\n <Item>Item 12</Item>\n <Item>Item 13</Item>\n <Item>Item 14</Item>\n <Item>Item 15</Item>\n <Item>Item 16</Item>\n <Item>Item 17</Item>\n <Item>Item 18</Item>\n <Item>Item 19</Item>\n <Item>Item 20</Item>\n <Item>Item 21</Item>\n <Item>Item 22</Item>\n <Item>Item 23</Item>\n <Item>Item 24</Item>\n <Item>Item 25</Item>\n <Item>Item 26</Item>\n <Item>Item 27</Item>\n <Item>Item 28</Item>\n <Item>Item 29</Item>\n <Item>Item 30</Item>\n </Section>\n <Section label=\"Section 2\" arrow={false}>\n <Item selected={true}>Item 1</Item>\n <Item>Item 2</Item>\n <Item>Item 3</Item>\n </Section>\n </TableView>\n );\n }\n}\n\nAppRegistry.registerComponent('TableViewExample', () => TableViewExample);\n```\n## Example 2 (JSON source support), reads country list JSON from app bundle and display UITableView with selected value checkmarked\n![demo2](https://cloud.githubusercontent.com/assets/1321329/9335801/7a4d42ca-45d6-11e5-860c-969db80413ca.gif)\n\n```\n render(){\n return (\n <TableView selectedValue=\"ES\" style={{flex:1}} json=\"countries\"\n tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}\n onPress={(event) => console.log(event)}/>\n );\n }\n```\n\n### Example 3 (JSON filter and optional items at the beginning)\n```\n // list spanish provinces and add 'All states' item at the beginning\n render(){\n var country = \"ES\";\n return (\n <TableView selectedValue=\"\" style={{flex:1}} json=\"states\" filter={`country=='${country}'`}\n tableViewCellStyle={TableView.Consts.CellStyle.Subtitle}\n onPress={(event) => console.log(event)}>\n <Item value=\"\">All states</Item>\n </TableView>\n );\n }\n```\n\n## Getting started\n1. `npm install react-native-tableview --save`\n2. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n3. add `./node_modules/react-native-tableview/RCTTableView.xcodeproj`\n4. In the XCode project navigator, select your project, select the `Build Phases` tab and in the `Link Binary With Libraries` section add **libRCTTableView.a**\n5. (optional) If you will use JSON file, add it to iOS application bundle\n6. `var TableView = require('react-native-tableview')`\n",
"readmeFilename": "README.md",
"gitHead": "bc76edf6b3181bea02f1e78c3c21a8cf9b2aacfe",
"_id": "react-native-tableview@1.1.0",
"_shasum": "32f732090613306e85f4a57eac649a48a5833dca",
"_from": "react-native-tableview@*"
"_id": "react-native-tableview@1.1.1",
"_shasum": "de6275dd85fbbe842939c399c88c1ed9fd0e4e58",
"_from": "react-native-tableview@>=1.0.4 <2.0.0"
}

0 comments on commit c722d37

Please sign in to comment.