diff --git a/RNTableView/RNTableView.m b/RNTableView/RNTableView.m index c519a80..decd07e 100644 --- a/RNTableView/RNTableView.m +++ b/RNTableView/RNTableView.m @@ -594,6 +594,15 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd [_sections[indexPath.section][@"items"] removeObjectAtIndex:indexPath.row]; [self.tableView reloadData]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + NSMutableDictionary *newValue = [self dataForRow:indexPath.item section:indexPath.section]; + newValue[@"target"] = self.reactTag; + newValue[@"selectedIndex"] = [NSNumber numberWithInteger:indexPath.item]; + newValue[@"selectedSection"] = [NSNumber numberWithInteger:indexPath.section]; + newValue[@"mode"] = @"insert"; + + self.onChange(newValue); + [self.tableView reloadData]; } } diff --git a/example/src/screens/Example6.js b/example/src/screens/Example6.js index 484b3cd..93de9bc 100644 --- a/example/src/screens/Example6.js +++ b/example/src/screens/Example6.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types' import { View, Button } from 'react-native' import TableView from 'react-native-tableview' -const { Item, Section } = TableView +const { Item, Section, Consts } = TableView class Example6 extends React.Component { static navigationOptions = ({ navigation }) => ({ @@ -34,10 +34,20 @@ class Example6 extends React.Component { Item 2 Item 3 Item 4 - Item 5 - Item 6 - Item 7 - Item 8 + + + alert(JSON.stringify(event))} + onChange={event => alert(`CHANGED:${JSON.stringify(event)}`)} + > +
+ Item 1 + Item 2 + Item 3 + Item 4