2021-01-23 07:15:52 +01:00
|
|
|
// Copyright © 2021 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import ViewModels
|
|
|
|
|
|
|
|
extension CollectionSection {
|
|
|
|
struct Identifier: Hashable {
|
|
|
|
let index: Int
|
2021-01-31 02:43:48 +01:00
|
|
|
let searchScope: SearchScope?
|
2021-01-23 07:15:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Array where Element == CollectionSection {
|
|
|
|
func snapshot() -> NSDiffableDataSourceSnapshot<CollectionSection.Identifier, CollectionItem> {
|
|
|
|
var snapshot = NSDiffableDataSourceSnapshot<CollectionSection.Identifier, CollectionItem>()
|
|
|
|
|
|
|
|
for (index, section) in enumerated() {
|
|
|
|
let identifier = CollectionSection.Identifier(
|
|
|
|
index: index,
|
2021-01-31 02:43:48 +01:00
|
|
|
searchScope: section.searchScope)
|
2021-01-23 07:15:52 +01:00
|
|
|
snapshot.appendSections([identifier])
|
|
|
|
snapshot.appendItems(section.items, toSection: identifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
return snapshot
|
|
|
|
}
|
|
|
|
}
|