Skip to content

Commit

Permalink
Fix brave/brave-ios#7755: Reinsert the favs overlay when bottom bar m…
Browse files Browse the repository at this point in the history
…ode changes (brave/brave-ios#8201)
  • Loading branch information
kylehickinson authored Oct 6, 2023
1 parent c28c7c9 commit 9993b8f
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 9993b8f

Please sign in to comment.