Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing navigation bar from blank preview #2487

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading