Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Add animationType to BatchUpdates #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/Views/BatchUpdates.swift
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 6 additions & 6 deletions Sources/Views/ReloadableView.swift
Original file line number Diff line number Diff line change
@@ -120,27 +120,27 @@ extension UITableView: ReloadableView {

// Update items.
if batchUpdates.insertItems.count > 0 {
insertRows(at: batchUpdates.insertItems, with: .automatic)
insertRows(at: batchUpdates.insertItems, with: batchUpdates.animationType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we control the animations on the collection view in a similar way? See line 70 in this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, in UIKit collection view doesn't have the same animation properties, you can only insert / delete / reload / move without any more possibility. :( That's why I only updated table view animations

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than 2 months since my last answer... Could you please at least read it ?

}
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)
}

// 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)