Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #7755: Reinsert the favs overlay when bottom bar mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Oct 6, 2023
1 parent 730c22f commit 597c235
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ public class BrowserViewController: UIViewController {
traitCollection.horizontalSizeClass == .compact &&
traitCollection.verticalSizeClass == .regular &&
traitCollection.userInterfaceIdiom == .phone

// Reinserts the fav controller whos parent is based on bottom bar
if let favoritesController {
insertFavoritesControllerView(favoritesController: favoritesController)
}
}

public override func viewSafeAreaInsetsDidChange() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,18 @@ extension BrowserViewController: TopToolbarDelegate {

favoritesController?.view.isHidden = true
}

func insertFavoritesControllerView(favoritesController: FavoritesViewController) {
if let ntpController = self.activeNewTabPageViewController, ntpController.parent != nil {
view.insertSubview(favoritesController.view, aboveSubview: ntpController.view)
} else {
// Two different behaviors here:
// 1. For bottom bar we do not want to show the status bar color
// 2. For top bar we do so it matches the address bar background
let subview = isUsingBottomBar ? statusBarOverlay : footer
view.insertSubview(favoritesController.view, aboveSubview: subview)
}
}

private func displayFavoritesController() {
if favoritesController == nil {
Expand Down Expand Up @@ -730,15 +742,7 @@ extension BrowserViewController: TopToolbarDelegate {
self.favoritesController = favoritesController

addChild(favoritesController)
if let ntpController = self.activeNewTabPageViewController, ntpController.parent != nil {
view.insertSubview(favoritesController.view, aboveSubview: ntpController.view)
} else {
// Two different behaviors here:
// 1. For bottom bar we do not want to show the status bar color
// 2. For top bar we do so it matches the address bar background
let subview = isUsingBottomBar ? statusBarOverlay : footer
view.insertSubview(favoritesController.view, aboveSubview: subview)
}
insertFavoritesControllerView(favoritesController: favoritesController)
favoritesController.didMove(toParent: self)

favoritesController.view.snp.makeConstraints {
Expand Down

0 comments on commit 597c235

Please sign in to comment.