From 679252d2bb74bab70cd98ce193ad66328269b1f8 Mon Sep 17 00:00:00 2001 From: Fabien Mirault Date: Thu, 4 Jan 2018 15:02:36 +0100 Subject: [PATCH] - Added animationType inside BatchUpdates, and used it for insertRows / deleteRows / reloadRows / insertSections / deleteSections / reloadSections --- Sources/Views/BatchUpdates.swift | 4 +++- Sources/Views/ReloadableView.swift | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Sources/Views/BatchUpdates.swift b/Sources/Views/BatchUpdates.swift index e2dc7755..15a6f08e 100644 --- a/Sources/Views/BatchUpdates.swift +++ b/Sources/Views/BatchUpdates.swift @@ -6,7 +6,7 @@ // software distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -import Foundation +import UIKit /** @@ -25,6 +25,8 @@ public class BatchUpdates: NSObject { public var deleteSections = IndexSet() public var reloadSections = IndexSet() public var moveSections = [SectionMove]() + + public var animationType: UITableViewRowAnimation = .automatic public override init() { super.init() diff --git a/Sources/Views/ReloadableView.swift b/Sources/Views/ReloadableView.swift index 4fb7f55c..7e890000 100644 --- a/Sources/Views/ReloadableView.swift +++ b/Sources/Views/ReloadableView.swift @@ -120,13 +120,13 @@ extension UITableView: ReloadableView { // Update items. if batchUpdates.insertItems.count > 0 { - insertRows(at: batchUpdates.insertItems, with: .automatic) + insertRows(at: batchUpdates.insertItems, with: batchUpdates.animationType) } if batchUpdates.deleteItems.count > 0 { - deleteRows(at: batchUpdates.deleteItems, with: .automatic) + deleteRows(at: batchUpdates.deleteItems, with: batchUpdates.animationType) } if batchUpdates.reloadItems.count > 0 { - reloadRows(at: batchUpdates.reloadItems, with: .automatic) + reloadRows(at: batchUpdates.reloadItems, with: batchUpdates.animationType) } for move in batchUpdates.moveItems { moveRow(at: move.from, to: move.to) @@ -134,13 +134,13 @@ extension UITableView: ReloadableView { // Update sections. if batchUpdates.insertSections.count > 0 { - insertSections(batchUpdates.insertSections, with: .automatic) + insertSections(batchUpdates.insertSections, with: batchUpdates.animationType) } if batchUpdates.deleteSections.count > 0 { - deleteSections(batchUpdates.deleteSections, with: .automatic) + deleteSections(batchUpdates.deleteSections, with: batchUpdates.animationType) } if batchUpdates.reloadSections.count > 0 { - reloadSections(batchUpdates.reloadSections, with: .automatic) + reloadSections(batchUpdates.reloadSections, with: batchUpdates.animationType) } for move in batchUpdates.moveSections { moveSection(move.from, toSection: move.to)