Skip to content

Commit 8a356cc

Browse files
committed
Added manage order in sections.
1 parent 84edb52 commit 8a356cc

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

SPDiffable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '1.3.3'
4+
s.version = '1.3.4'
55
s.summary = 'Extenshion of Diffable API which allow not duplicate code and use less models.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
8585
// Remove section if it deleted from content.
8686

8787
var snapshot = self.snapshot()
88+
8889
let deletedSections = snapshot.sectionIdentifiers.filter({ (checkSection) -> Bool in
8990
return !sections.contains(where: { $0.identifier == checkSection.identifier })
9091
})
@@ -93,6 +94,19 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
9394
apply(snapshot, animated: true)
9495
}
9596

97+
// Reoder
98+
99+
for (sectionIndex, section) in sections.enumerated() {
100+
let beforeSectionIndex = sectionIndex - 1
101+
guard (sections.count > beforeSectionIndex) && (beforeSectionIndex >= 0) else { continue }
102+
let afterSection = sections[beforeSectionIndex]
103+
snapshot.moveSection(section, afterSection: afterSection)
104+
}
105+
106+
// Apply Sections Changes
107+
108+
apply(snapshot, animated: true)
109+
96110
// Update current sections.
97111

98112
for section in sections {

0 commit comments

Comments
 (0)