mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-08-03 20:47:22 -04:00
Fix menu item configurations
This commit is contained in:
parent
3b45af00f8
commit
dcbb1feb3b
@ -59,13 +59,13 @@ final class SidebarViewController: UICollectionViewController, NSFetchedResultsC
|
|||||||
static var allSections: [Section] {
|
static var allSections: [Section] {
|
||||||
switch (FeatureFlags.hasLibrary, Brand.hideDonation) {
|
switch (FeatureFlags.hasLibrary, Brand.hideDonation) {
|
||||||
case (true, true):
|
case (true, true):
|
||||||
allCases.filter { [.donation].contains($0) }
|
allCases.filter { ![.donation].contains($0) }
|
||||||
case (false, true):
|
case (false, true):
|
||||||
allCases.filter { [.donation, .library].contains($0) }
|
allCases.filter { ![.donation, .library].contains($0) }
|
||||||
case (true, false):
|
case (true, false):
|
||||||
allCases
|
allCases
|
||||||
case (false, false):
|
case (false, false):
|
||||||
allCases.filter { [.library].contains($0) }
|
allCases.filter { ![.library].contains($0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,11 +133,15 @@ final class SidebarViewController: UICollectionViewController, NSFetchedResultsC
|
|||||||
// apply initial snapshot
|
// apply initial snapshot
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<Section, MenuItem>()
|
var snapshot = NSDiffableDataSourceSnapshot<Section, MenuItem>()
|
||||||
snapshot.appendSections(Section.allSections)
|
snapshot.appendSections(Section.allSections)
|
||||||
snapshot.appendItems([.bookmarks], toSection: .primary)
|
if snapshot.sectionIdentifiers.contains(.primary) {
|
||||||
|
snapshot.appendItems([.bookmarks], toSection: .primary)
|
||||||
|
}
|
||||||
if snapshot.sectionIdentifiers.contains(.library) {
|
if snapshot.sectionIdentifiers.contains(.library) {
|
||||||
snapshot.appendItems([.opened, .categories, .downloads, .new], toSection: .library)
|
snapshot.appendItems([.opened, .categories, .downloads, .new], toSection: .library)
|
||||||
}
|
}
|
||||||
snapshot.appendItems([.settings], toSection: .settings)
|
if snapshot.sectionIdentifiers.contains(.settings) {
|
||||||
|
snapshot.appendItems([.settings], toSection: .settings)
|
||||||
|
}
|
||||||
if snapshot.sectionIdentifiers.contains(.donation) {
|
if snapshot.sectionIdentifiers.contains(.donation) {
|
||||||
snapshot.appendItems([.donation], toSection: .donation)
|
snapshot.appendItems([.donation], toSection: .donation)
|
||||||
}
|
}
|
||||||
@ -239,6 +243,10 @@ final class SidebarViewController: UICollectionViewController, NSFetchedResultsC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func configureHeader(headerView: UICollectionViewListCell, elementKind: String, indexPath: IndexPath) {
|
private func configureHeader(headerView: UICollectionViewListCell, elementKind: String, indexPath: IndexPath) {
|
||||||
|
guard Section.allSections.indices.contains(indexPath.section) else {
|
||||||
|
headerView.contentConfiguration = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
let section = Section.allSections[indexPath.section]
|
let section = Section.allSections[indexPath.section]
|
||||||
switch section {
|
switch section {
|
||||||
case .tabs:
|
case .tabs:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user