diff --git a/RNTableView/RNTableView.m b/RNTableView/RNTableView.m index 51dae24..15e6ca2 100644 --- a/RNTableView/RNTableView.m +++ b/RNTableView/RNTableView.m @@ -604,8 +604,12 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd self.onChange(newValue); - [_sections[indexPath.section][@"items"] removeObjectAtIndex:indexPath.row]; - [self.tableView reloadData]; + if ([newValue[@"shouldOnlyEdit"] boolValue]) { + [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + } else { + [_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; @@ -618,6 +622,11 @@ - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEd } } +- (nullable NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath { + NSDictionary *item = [self dataForRow:indexPath.item section:indexPath.section]; + return item[@"buttonTitleOnEdit"] ? item[@"buttonTitleOnEdit"]: @"Delete"; +} + -(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ return self.tableViewCellEditingStyle; diff --git a/src/index.d.ts b/src/index.d.ts index 4eaf60a..9d6e118 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -187,10 +187,20 @@ interface ItemProps { canMove?: boolean /** - * If cell can be deleted in editing mode + * If cell can be deleted or edited in editing mode */ canEdit?: boolean + /** + * If cell should be only edited without deletion of the cell in editing mode + */ + shouldOnlyEdit?: boolean + + /** + * Custom button title in editing mode, default is "Delete" without localization support + */ + buttonTitleOnEdit?: string + /** * Cell selection style */