diff options
author | Aleksey Belousov <aleksey.belousov@corp.mail.ru> | 2018-05-07 14:40:47 +0300 |
---|---|---|
committer | Vlad Mihaylenko <vxmihaylenko@gmail.com> | 2018-05-07 17:18:09 +0300 |
commit | fe79e12bc2495eeda70d9d13c12463e0a1b95393 (patch) | |
tree | abae52cb05bab7ec90abf34bdd69740d338faf84 | |
parent | 358471a06c8216e1f93ea711012e911900bb7e9c (diff) |
Use BMCView protocol methods for insert/delete rows. Also updated BMCView protocol to be more flexible (insert/delete multiple rows)
3 files changed, 10 insertions, 10 deletions
diff --git a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift index 027033e4b1..2c8fa72f8d 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift @@ -160,12 +160,12 @@ extension BMCViewController: BMCView { } } - func insert(at indexPath: IndexPath) { - tableView.insertRows(at: [indexPath], with: .automatic) + func insert(at indexPaths: [IndexPath]) { + tableView.insertRows(at: indexPaths, with: .automatic) } - func delete(at indexPath: IndexPath) { - tableView.deleteRows(at: [indexPath], with: .automatic) + func delete(at indexPaths: [IndexPath]) { + tableView.deleteRows(at: indexPaths, with: .automatic) } func conversionFinished(success: Bool) { @@ -310,9 +310,9 @@ extension BMCViewController: BMCPermissionsHeaderDelegate { rowIndexes.append(IndexPath(row: rowIndex, section: sectionIndex)) } if (permissionsHeader.isCollapsed) { - tableView.deleteRows(at: rowIndexes, with: .automatic) + delete(at: rowIndexes) } else { - tableView.insertRows(at: rowIndexes, with: .automatic) + insert(at: rowIndexes) } } } diff --git a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift index 5156111b2c..91c0cafdc9 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCDefaultViewModel.swift @@ -137,7 +137,7 @@ extension BMCDefaultViewModel: BMCViewModel { } categories.append(BMCCategory(identifier: BM.createCategory(withName: name), title: name)) - view.insert(at: IndexPath(row: categories.count - 1, section: section)) + view.insert(at: [IndexPath(row: categories.count - 1, section: section)]) } func renameCategory(category: BMCCategory, name: String) { @@ -154,7 +154,7 @@ extension BMCDefaultViewModel: BMCViewModel { categories.remove(at: row) BM.deleteCategory(category.identifier) - view.delete(at: IndexPath(row: row, section: section)) + view.delete(at: [IndexPath(row: row, section: section)]) } func checkCategory(name: String) -> Bool { diff --git a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCViewModel.swift b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCViewModel.swift index 39df47227a..71393c530e 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCViewModel.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCViewModel/BMCViewModel.swift @@ -1,7 +1,7 @@ protocol BMCView: AnyObject { func update(sections: [BMCSection]) - func delete(at indexPath: IndexPath) - func insert(at indexPath: IndexPath) + func delete(at indexPaths: [IndexPath]) + func insert(at indexPaths: [IndexPath]) func conversionFinished(success: Bool) } |