Skip to content

Commit

Permalink
fix missing navigation bar from blank preview (#2487)
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy authored Feb 19, 2024
1 parent dad7d33 commit 30cc083
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions DuckDuckGo/BlankSnapshotViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ class BlankSnapshotViewController: UIViewController {
}

private func configureOmniBar() {
viewCoordinator.navigationBarCollectionView.register(OmniBarCell.self, forCellWithReuseIdentifier: "omnibar")
viewCoordinator.navigationBarCollectionView.isPagingEnabled = true

let layout = viewCoordinator.navigationBarCollectionView.collectionViewLayout as? UICollectionViewFlowLayout
layout?.scrollDirection = .horizontal
layout?.itemSize = CGSize(width: viewCoordinator.superview.frame.size.width, height: viewCoordinator.omniBar.frame.height)
layout?.minimumLineSpacing = 0
layout?.minimumInteritemSpacing = 0
layout?.scrollDirection = .horizontal

viewCoordinator.navigationBarCollectionView.dataSource = self
if AppWidthObserver.shared.isLargeWidth {
viewCoordinator.omniBar.enterPadState()
}
Expand All @@ -126,6 +137,25 @@ class BlankSnapshotViewController: UIViewController {
}
}

extension BlankSnapshotViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "omnibar", for: indexPath) as? OmniBarCell else {
fatalError("Not \(OmniBarCell.self)")
}
cell.omniBar = viewCoordinator.omniBar
return cell
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

}

extension BlankSnapshotViewController: OmniBarDelegate {

func onVoiceSearchPressed() {
Expand Down

0 comments on commit 30cc083

Please sign in to comment.