@@ -103,14 +103,13 @@ extension UITableView: DeltaUpdatableView {
103
103
104
104
public func reloadSections( for sectionUpdates: [ SectionUpdate ] ) {
105
105
106
- performBatchUpdates ( { [ weak self] in
106
+ performBatchUpdates ( . reload , delegates : sectionUpdates . uniqueAnimationDelegates , { [ weak self] in
107
107
sectionUpdates. forEach { sectionUpdate in
108
108
sectionUpdate. update ( )
109
- guard self != nil else { return }
109
+ guard let self else { return }
110
110
let indexSet = IndexSet ( [ sectionUpdate. section] )
111
- reloadSections ( indexSet, with: preferredReloadSectionAnimation ( for: sectionUpdate. section) )
111
+ self . reloadSections ( indexSet, with: self . preferredReloadSectionAnimation ( for: sectionUpdate. section) )
112
112
}
113
- sectionUpdates. uniqueAnimationDelegates. forEach { $0. animateAlongsideUpdate ( with: TimeInterval . standardCollectionAnimationDuration) }
114
113
} , completion: { _ in
115
114
sectionUpdates. forEach { $0. completion ? ( ) }
116
115
} )
@@ -202,11 +201,10 @@ extension UICollectionView: DeltaUpdatableView {
202
201
let sections = sectionUpdates. map { $0. section }
203
202
let indexSet = IndexSet ( sections)
204
203
205
- performBatchUpdates ( { [ weak self] in
204
+ performBatchUpdates ( . reload , delegates : sectionUpdates . uniqueAnimationDelegates , { [ weak self] in
206
205
sectionUpdates. forEach { $0. update ( ) }
207
- guard self != nil else { return }
208
- reloadSections ( indexSet)
209
- sectionUpdates. uniqueAnimationDelegates. forEach { $0. animateAlongsideUpdate ( with: TimeInterval . standardCollectionAnimationDuration) }
206
+ guard let self else { return }
207
+ self . reloadSections ( indexSet)
210
208
} , completion: { _ in
211
209
sectionUpdates. forEach { $0. completion ? ( ) }
212
210
} )
@@ -464,13 +462,13 @@ private extension Sequence where Element == SectionUpdate {
464
462
465
463
// MARK: AnimationDelegate Helper
466
464
467
- private extension UITableView {
465
+ extension UITableView {
468
466
469
- func performBatchUpdates( _ group: CollectionDataAnimationGroup , delegates: [ CollectionDataAnimationDelegate ] , _ updates: ( ( ) -> Void ) ? , completion: ( ( Bool ) -> Void ) ? = nil ) {
467
+ func performBatchUpdates( _ group: CollectionDataAnimationGroup , delegates: [ CollectionDataAnimationDelegate ] , _ updates: ( ) -> Void , completion: ( ( Bool ) -> Void ) ? = nil ) {
470
468
delegates. forEach { $0. animateAlongsideUpdate ( for: . immediatelyBefore( group: group, duration: TimeInterval . standardCollectionAnimationDuration) ) }
471
469
472
470
performBatchUpdates {
473
- updates ? ( )
471
+ updates ( )
474
472
delegates. forEach { $0. animateAlongsideUpdate ( for: . during( group: group, duration: TimeInterval . standardCollectionAnimationDuration) ) }
475
473
} completion: { value in
476
474
completion ? ( value)
@@ -481,13 +479,13 @@ private extension UITableView {
481
479
}
482
480
}
483
481
484
- private extension UICollectionView {
482
+ extension UICollectionView {
485
483
486
- func performBatchUpdates( _ group: CollectionDataAnimationGroup , delegates: [ CollectionDataAnimationDelegate ] , _ updates: ( ( ) -> Void ) ? , completion: ( ( Bool ) -> Void ) ? = nil ) {
484
+ func performBatchUpdates( _ group: CollectionDataAnimationGroup , delegates: [ CollectionDataAnimationDelegate ] , _ updates: ( ) -> Void , completion: ( ( Bool ) -> Void ) ? = nil ) {
487
485
delegates. forEach { $0. animateAlongsideUpdate ( for: . immediatelyBefore( group: group, duration: TimeInterval . standardCollectionAnimationDuration) ) }
488
486
489
487
performBatchUpdates {
490
- updates ? ( )
488
+ updates ( )
491
489
delegates. forEach { $0. animateAlongsideUpdate ( for: . during( group: group, duration: TimeInterval . standardCollectionAnimationDuration) ) }
492
490
} completion: { value in
493
491
completion ? ( value)
0 commit comments