@@ -18,6 +18,20 @@ func indexSet(_ values: [Int]) -> IndexSet {
18
18
return indexSet as IndexSet
19
19
}
20
20
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
+
21
35
public protocol SectionedNodeType {
22
36
func insertItemsAtIndexPaths( _ paths: [ IndexPath ] , animationStyle: UITableViewRowAnimation )
23
37
func deleteItemsAtIndexPaths( _ paths: [ IndexPath ] , animationStyle: UITableViewRowAnimation )
@@ -35,26 +49,26 @@ public protocol SectionedNodeType {
35
49
func _performBatchUpdates< V: SectionedNodeType , S: SectionModelType > ( _ view: V , changes: Changeset < S > , animationConfiguration: RowAnimation ) {
36
50
typealias I = S . Item
37
51
38
- view. deleteSections ( changes. deletedSections, animationStyle: . fade )
52
+ view. deleteSections ( changes. deletedSections, animationStyle: animationConfiguration . deleteAnimation )
39
53
// Updated sections doesn't mean reload entire section, somebody needs to update the section view manually
40
54
// otherwise all cells will be reloaded for nothing.
41
55
//view.reloadSections(changes.updatedSections, animationStyle: rowAnimation)
42
- view. insertSections ( changes. insertedSections, animationStyle: . fade )
56
+ view. insertSections ( changes. insertedSections, animationStyle: animationConfiguration . insertAnimation )
43
57
for (from, to) in changes. movedSections {
44
58
view. moveSection ( from, to: to)
45
59
}
46
60
47
61
view. deleteItemsAtIndexPaths (
48
62
changes. deletedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
49
- animationStyle: . fade
63
+ animationStyle: animationConfiguration . deleteAnimation
50
64
)
51
65
view. insertItemsAtIndexPaths (
52
66
changes. insertedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
53
- animationStyle: . fade
67
+ animationStyle: animationConfiguration . insertAnimation
54
68
)
55
69
view. reloadItemsAtIndexPaths (
56
70
changes. updatedItems. map { IndexPath ( item: $0. itemIndex, section: $0. sectionIndex) } ,
57
- animationStyle: . fade
71
+ animationStyle: animationConfiguration . reloadAnimation
58
72
)
59
73
60
74
for (from, to) in changes. movedItems {
0 commit comments