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

Fix #7755: Reinsert the favs overlay when bottom bar mode changes #8201

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
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
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