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

Commit

Permalink
Fixes #2659 - Search bar has wrong appearance when refocused (#2680) (#…
Browse files Browse the repository at this point in the history
…2688)

Co-authored-by: Bogdan Cernea <[email protected]>
Co-authored-by: Stefan Arentz <[email protected]>
(cherry picked from commit 7f758aa)

Co-authored-by: Bogdan Cernea <[email protected]>
  • Loading branch information
mergify[bot] and bogdancernea28 authored Oct 22, 2021
1 parent 311a20a commit f3a11e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Blockzilla/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ class BrowserViewController: UIViewController {
private func toggleURLBarBackground(isBright: Bool) {
if urlBar.isEditing {
urlBarContainer.barState = .editing
}
if urlBar.inBrowsingMode {
urlBarContainer.barState = .browsing
} else if case .on = trackingProtectionStatus {
urlBarContainer.barState = .bright
} else {
Expand Down
13 changes: 12 additions & 1 deletion Blockzilla/URLBarContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import UIKit

class URLBarContainer: UIView {
private let backgroundEditing = UIView()
private let backgroundBrowsing = UIView()
private let backgroundDark = UIView()
private let backgroundBright = UIView()

Expand All @@ -14,6 +15,9 @@ class URLBarContainer: UIView {

backgroundEditing.backgroundColor = .clear
addSubview(backgroundEditing)

backgroundBrowsing.backgroundColor = .foundation
addSubview(backgroundBrowsing)

backgroundDark.backgroundColor = UIConstants.colors.background
backgroundDark.isHidden = true
Expand All @@ -36,15 +40,20 @@ class URLBarContainer: UIView {
backgroundEditing.snp.makeConstraints { make in
make.edges.equalTo(self)
}

backgroundBrowsing.snp.makeConstraints { make in
make.edges.equalTo(self)
}
}

enum BarState {
case bright
case dark
case editing
case browsing
}

var barState: BarState = .editing {
var barState: BarState = .browsing {
didSet {
guard barState != oldValue else { return }

Expand Down Expand Up @@ -80,6 +89,8 @@ class URLBarContainer: UIView {
return backgroundDark
case .editing:
return backgroundEditing
case .browsing:
return backgroundBrowsing
}
}
}

0 comments on commit f3a11e7

Please sign in to comment.