|
| 1 | +import UIKit |
1 | 2 | /**
|
2 | 3 | ImmuTable represents the view model for a static UITableView.
|
3 | 4 |
|
@@ -291,6 +292,26 @@ open class ImmuTableViewHandler: NSObject, UITableViewDataSource, UITableViewDel
|
291 | 292 | return viewModel.sections[section].footerText
|
292 | 293 | }
|
293 | 294 |
|
| 295 | + open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { |
| 296 | + if target.responds(to: #selector(UITableViewDataSource.tableView(_:canEditRowAt:))) { |
| 297 | + return target.tableView?(tableView, canEditRowAt: indexPath) ?? false |
| 298 | + } |
| 299 | + |
| 300 | + return false |
| 301 | + } |
| 302 | + |
| 303 | + open func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { |
| 304 | + if target.responds(to: #selector(UITableViewDataSource.tableView(_:canMoveRowAt:))) { |
| 305 | + return target.tableView?(tableView, canMoveRowAt: indexPath) ?? false |
| 306 | + } |
| 307 | + |
| 308 | + return false |
| 309 | + } |
| 310 | + |
| 311 | + open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { |
| 312 | + target.tableView?(tableView, moveRowAt: sourceIndexPath, to: destinationIndexPath) |
| 313 | + } |
| 314 | + |
294 | 315 | // MARK: UITableViewDelegate
|
295 | 316 |
|
296 | 317 | open func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
|
@@ -352,14 +373,27 @@ open class ImmuTableViewHandler: NSObject, UITableViewDataSource, UITableViewDel
|
352 | 373 | return nil
|
353 | 374 | }
|
354 | 375 |
|
355 |
| - open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { |
356 |
| - if target.responds(to: #selector(UITableViewDataSource.tableView(_:canEditRowAt:))) { |
357 |
| - return target.tableView?(tableView, canEditRowAt: indexPath) ?? false |
| 376 | + open func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath { |
| 377 | + if target.responds(to: #selector(UITableViewDelegate.tableView(_:targetIndexPathForMoveFromRowAt:toProposedIndexPath:))) { |
| 378 | + return target.tableView?(tableView, targetIndexPathForMoveFromRowAt: sourceIndexPath, toProposedIndexPath: proposedDestinationIndexPath) ?? proposedDestinationIndexPath |
358 | 379 | }
|
359 | 380 |
|
360 |
| - return false |
| 381 | + return proposedDestinationIndexPath |
361 | 382 | }
|
362 | 383 |
|
| 384 | + open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { |
| 385 | + if target.responds(to: #selector(UITableViewDelegate.tableView(_:editingStyleForRowAt:))) { |
| 386 | + return target.tableView?(tableView, editingStyleForRowAt: indexPath) ?? .none |
| 387 | + } |
| 388 | + |
| 389 | + return .none |
| 390 | + } |
| 391 | + |
| 392 | + open func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { |
| 393 | + return target.tableView?(tableView, shouldIndentWhileEditingRowAt: indexPath) ?? true |
| 394 | + } |
| 395 | + |
| 396 | + |
363 | 397 | public func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
364 | 398 | if target.responds(to: #selector(UITableViewDelegate.tableView(_:trailingSwipeActionsConfigurationForRowAt:))) {
|
365 | 399 | return target.tableView?(tableView, trailingSwipeActionsConfigurationForRowAt: indexPath)
|
|
0 commit comments