@@ -18,6 +18,20 @@ func indexSet(_ values: [Int]) -> IndexSet {
1818 return indexSet as IndexSet
1919}
2020
21+ public struct RowAnimation {
22+ public let insertAnimation : UITableViewRowAnimation
23+ public let reloadAnimation : UITableViewRowAnimation
24+ public let deleteAnimation : UITableViewRowAnimation
25+
26+ public init ( insertAnimation: UITableViewRowAnimation = . automatic,
27+ reloadAnimation: UITableViewRowAnimation = . automatic,
28+ deleteAnimation: UITableViewRowAnimation = . automatic) {
29+ self . insertAnimation = insertAnimation
30+ self . reloadAnimation = reloadAnimation
31+ self . deleteAnimation = deleteAnimation
32+ }
33+ }
34+
2135public protocol SectionedNodeType {
2236 func insertItemsAtIndexPaths( _ paths: [ IndexPath ] , animationStyle: UITableViewRowAnimation )
2337 func deleteItemsAtIndexPaths( _ paths: [ IndexPath ] , animationStyle: UITableViewRowAnimation )
@@ -35,26 +49,26 @@ public protocol SectionedNodeType {
3549func _performBatchUpdates< V: SectionedNodeType , S: SectionModelType > ( _ view: V , changes: Changeset < S > , animationConfiguration: RowAnimation ) {
3650 typealias I = S . Item
3751
38- view. deleteSections ( changes. deletedSections, animationStyle: . fade )
52+ view. deleteSections ( changes. deletedSections, animationStyle: animationConfiguration . deleteAnimation )
3953 // Updated sections doesn't mean reload entire section, somebody needs to update the section view manually
4054 // otherwise all cells will be reloaded for nothing.
4155 //view.reloadSections(changes.updatedSections, animationStyle: rowAnimation)
42- view. insertSections ( changes. insertedSections, animationStyle: . fade )
56+ view. insertSections ( changes. insertedSections, animationStyle: animationConfiguration . insertAnimation )
4357 for (from, to) in changes. movedSections {
4458 view. moveSection ( from, to: to)
4559 }
4660
4761 view. deleteItemsAtIndexPaths (
4862 changes. deletedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
49- animationStyle: . fade
63+ animationStyle: animationConfiguration . deleteAnimation
5064 )
5165 view. insertItemsAtIndexPaths (
5266 changes. insertedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
53- animationStyle: . fade
67+ animationStyle: animationConfiguration . insertAnimation
5468 )
5569 view. reloadItemsAtIndexPaths (
5670 changes. updatedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
57- animationStyle: . fade
71+ animationStyle: animationConfiguration . reloadAnimation
5872 )
5973
6074 for (from, to) in changes. movedItems {
0 commit comments