From dcdf9434d620a2beec91812f2d30e1128af948a2 Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Thu, 14 Sep 2023 14:41:30 -0400 Subject: [PATCH] Fix #8078: Update browser colors --- .../Brave/Extensions/SceneExtensions.swift | 8 + .../Frontend/Browser/BrowserColors.swift | 263 ++++++++++++++++++ .../Browser/BrowserViewController.swift | 28 +- ...rowserViewController+ToolbarDelegate.swift | 8 +- .../Favorites/FavoritesViewController.swift | 32 ++- .../PrivateBrowsingManager.swift | 4 + .../Frontend/Browser/ReaderModeBarView.swift | 31 +-- .../Search/BraveSearchPromotionCell.swift | 2 +- .../Browser/Search/SearchSuggestionCell.swift | 2 +- .../Search/SearchSuggestionsPromptView.swift | 2 +- .../Browser/Search/SearchViewController.swift | 56 ++-- .../Browser/Tabs/TabBar/TabBarCell.swift | 58 +--- .../Tabs/TabBar/TabsBarViewController.swift | 24 +- .../TabTrayController+TableViewDelegate.swift | 7 +- .../Tabs/TabTray/TabTrayController.swift | 59 ++-- .../TabTray/Views/TabSyncContainerView.swift | 4 +- .../TabTray/Views/TabTrayContainerView.swift | 3 +- .../Views/TabTrayPrivateModeInfoView.swift | 2 - .../BottomToolbar/BottomToolbarView.swift | 29 +- .../Menu/EmptyStateOverlayView.swift | 2 - .../Toolbars/HeaderContainerView.swift | 31 +-- .../Browser/Toolbars/ToolbarButton.swift | 57 ++-- .../Browser/Toolbars/ToolbarHelper.swift | 9 +- .../Toolbars/UrlBar/CollapsedURLBarView.swift | 14 +- .../Toolbars/UrlBar/TabLocationView.swift | 46 +-- .../Toolbars/UrlBar/TopToolbarView.swift | 41 ++- .../Brave/Frontend/Widgets/TabsButton.swift | 18 +- Sources/BraveUI/Buttons/InsetButton.swift | 2 +- .../DesignSystem/Colors/LegacyColors.swift | 28 -- 29 files changed, 564 insertions(+), 306 deletions(-) create mode 100644 Sources/Brave/Frontend/Browser/BrowserColors.swift diff --git a/Sources/Brave/Extensions/SceneExtensions.swift b/Sources/Brave/Extensions/SceneExtensions.swift index cd564927435..95f074d2b79 100644 --- a/Sources/Brave/Extensions/SceneExtensions.swift +++ b/Sources/Brave/Extensions/SceneExtensions.swift @@ -26,6 +26,14 @@ extension UIWindowScene { public var browserViewController: BrowserViewController? { return browserViewControllers.first } + + /// Returns the browser colors of the current window scene + var browserColors: any BrowserColors { + if let bvc = browserViewController, bvc.privateBrowsingManager.isPrivateBrowsing { + return .privateMode + } + return .standard + } } extension UIViewController { diff --git a/Sources/Brave/Frontend/Browser/BrowserColors.swift b/Sources/Brave/Frontend/Browser/BrowserColors.swift new file mode 100644 index 00000000000..0291ba39b8b --- /dev/null +++ b/Sources/Brave/Frontend/Browser/BrowserColors.swift @@ -0,0 +1,263 @@ +// Copyright 2023 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import Foundation +import UIKit +import DesignSystem +import BraveUI + +/// A set of browser theme colors found in the `🦁 Browser` Figma doc. There will be a separate set depending +/// on the browsing mode you're in (standard vs private) +protocol BrowserColors { + // MARK: - Text + var textPrimary: UIColor { get } + var textSecondary: UIColor { get } + var textTertiary: UIColor { get } + var textDisabled: UIColor { get } + var textInteractive: UIColor { get } + + // MARK: - Icon + var iconDefault: UIColor { get } + var iconDisabled: UIColor { get } + var iconActive: UIColor { get } + + // MARK: - BrowserButton + var browserButtonBackgroundHover: UIColor { get } + var browserButtonBackgroundActive: UIColor { get } + + // MARK: - TabSwitcher + var tabSwitcherButton: UIColor { get } + var tabSwitcherBackground: UIColor { get } + + // MARK: - Container + var containerBackground: UIColor { get } + var containerInteractive: UIColor { get } + var containerScrim: UIColor { get } + var containerFrostedGlass: UIColor { get } + + // MARK: - Chrome + var chromeBackground: UIColor { get } + + // MARK: - Divider + var dividerSubtle: UIColor { get } + var dividerStrong: UIColor { get } + + // MARK: - TabBar + var tabBarTabBackground: UIColor { get } + var tabBarTabActiveBackground: UIColor { get } +} + +extension BrowserColors where Self == StandardBrowserColors { + /// The standard set of light & dark mode browser colors + static var standard: StandardBrowserColors { .init() } +} + +extension BrowserColors where Self == PrivateModeBrowserColors { + /// The set of browser colors specific to private mode + static var privateMode: PrivateModeBrowserColors { .init() } +} + +/// The standard set of light & dark mode browser colors +struct StandardBrowserColors: BrowserColors { + var textPrimary: UIColor { + .init(light: .primitiveGray100, dark: .primitiveGray1) + } + + var textSecondary: UIColor { + .init(light: .primitiveGray70, dark: .primitiveGray30) + } + + var textTertiary: UIColor { + .init(light: .primitiveGray50, dark: .primitiveGray40) + } + + var textDisabled: UIColor { + .init(lightRGBA: 0x21242A80, darkRGBA: 0xEDEEF180) + } + + var textInteractive: UIColor { + .init(light: .primitivePrimary60, dark: .primitivePrimary40) + } + + var iconDefault: UIColor { + .init(light: .primitiveGray50, dark: .primitiveGray40) + } + + var iconDisabled: UIColor { + .init(lightRGBA: 0x68748580, darkRGBA: 0xA1ABBA80) + } + + var iconActive: UIColor { + .init(light: .primitivePrimary60, dark: .primitivePrimary40) + } + + var browserButtonBackgroundHover: UIColor { + .init(light: .primitiveGray10, dark: .primitiveGray80) + } + + var browserButtonBackgroundActive: UIColor { + .init(light: .primitiveGray20, dark: .primitiveGray100) + } + + var tabSwitcherButton: UIColor { + .init(lightColor: .white, darkColor: .init(braveSystemName: .primitiveGray90)) + } + + var tabSwitcherBackground: UIColor { + .init(light: .primitiveGray1, dark: .primitiveGray80) + } + + var containerBackground: UIColor { + .init(lightColor: .white, darkColor: .init(braveSystemName: .primitiveGray90)) + } + + var containerInteractive: UIColor { + .init(light: .primitivePrimary10, dark: .primitivePrimary80) + } + + var containerScrim: UIColor { + .init(lightRGBA: 0x0D0F1459, darkRGBA: 0x0D0F14B3) + } + + var containerFrostedGlass: UIColor { + .init(lightRGBA: 0xFFFFFFF7, darkRGBA: 0x21242AEB) + } + + var chromeBackground: UIColor { + .init(light: .primitiveGray1, dark: .primitiveGray100) + } + + var dividerSubtle: UIColor { + .init(lightRGBA: 0xA1ABBA66, darkRGBA: 0x68748566) + } + + var dividerStrong: UIColor { + .init(lightRGBA: 0x68748566, darkRGBA: 0xA1ABBA66) + } + + var tabBarTabBackground: UIColor { + .init(light: .primitiveGray10, dark: .primitiveGray100) + } + + var tabBarTabActiveBackground: UIColor { + .init(light: .primitiveGray1, dark: .primitiveGray90) + } +} + +/// The set of browser colors specific to private mode +struct PrivateModeBrowserColors: BrowserColors { + var textPrimary: UIColor { + .init(braveSystemName: .primitivePrivateWindow1) + } + + var textSecondary: UIColor { + .init(braveSystemName: .primitivePrivateWindow30) + } + + var textTertiary: UIColor { + .init(braveSystemName: .primitivePrivateWindow40) + } + + var textDisabled: UIColor { + .init(rgba: 0xEEEBFF80) + } + + var textInteractive: UIColor { + .init(braveSystemName: .primitivePrimary40) + } + + var iconDefault: UIColor { + .init(braveSystemName: .primitivePrivateWindow40) + } + + var iconDisabled: UIColor { + .init(rgba: 0xA380FF80) + } + + var iconActive: UIColor { + .init(braveSystemName: .primitivePrimary40) + } + + var browserButtonBackgroundHover: UIColor { + .init(braveSystemName: .primitivePrivateWindow80) + } + + var browserButtonBackgroundActive: UIColor { + .init(braveSystemName: .primitivePrivateWindow100) + } + + var tabSwitcherButton: UIColor { + .init(braveSystemName: .primitivePrimary90) + } + + var tabSwitcherBackground: UIColor { + .init(braveSystemName: .primitivePrimary80) + } + + var containerBackground: UIColor { + .init(braveSystemName: .primitivePrivateWindow90) + } + + var containerInteractive: UIColor { + .init(braveSystemName: .primitivePrimary90) + } + + var containerScrim: UIColor { + .init(rgba: 0x13052AB3) + } + + var containerFrostedGlass: UIColor { + .init(rgba: 0x2A0D58EB) + } + + var chromeBackground: UIColor { + .init(braveSystemName: .primitivePrivateWindow100) + } + + var dividerSubtle: UIColor { + .init(rgba: 0x7B63BF66) + } + + var dividerStrong: UIColor { + .init(rgba: 0xA380FF66) + } + + var tabBarTabBackground: UIColor { + .init(braveSystemName: .primitivePrivateWindow100) + } + + var tabBarTabActiveBackground: UIColor { + .init(braveSystemName: .primitivePrivateWindow90) + } +} + +extension UIColor { + fileprivate convenience init(light: FigmaColorResource, dark: FigmaColorResource) { + self.init(dynamicProvider: { traitCollection in + if traitCollection.userInterfaceStyle == .dark { + return .init(braveSystemName: dark) + } + return .init(braveSystemName: light) + }) + } + + fileprivate convenience init(lightColor: UIColor, darkColor: UIColor) { + self.init(dynamicProvider: { traitCollection in + if traitCollection.userInterfaceStyle == .dark { + return darkColor + } + return lightColor + }) + } + + fileprivate convenience init(lightRGBA: UInt32, darkRGBA: UInt32) { + self.init(dynamicProvider: { traitCollection in + if traitCollection.userInterfaceStyle == .dark { + return .init(rgba: darkRGBA) + } + return .init(rgba: lightRGBA) + }) + } +} diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 9794aa07649..e5401c57115 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -102,10 +102,10 @@ public class BrowserViewController: UIViewController { var readerModeBar: ReaderModeBarView? var readerModeCache: ReaderModeCache - let statusBarOverlay: UIView = { + private(set) lazy var statusBarOverlay: UIView = { // Temporary work around for covering the non-clipped web view content let statusBarOverlay = UIView() - statusBarOverlay.backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground + statusBarOverlay.backgroundColor = privateBrowsingManager.browserColors.chromeBackground return statusBarOverlay }() @@ -898,9 +898,12 @@ public class BrowserViewController: UIViewController { privateModeCancellable = privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() + .receive(on: RunLoop.main) .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateStatusBarOverlayColor() - self?.bottomBarKeyboardBackground.backgroundColor = self?.topToolbar.backgroundColor + guard let self = self else { return } + self.updateStatusBarOverlayColor() + self.bottomBarKeyboardBackground.backgroundColor = self.topToolbar.backgroundColor + self.collapsedURLBarView.browserColors = self.privateBrowsingManager.browserColors }) appReviewCancelable = AppReviewManager.shared @@ -917,14 +920,6 @@ public class BrowserViewController: UIViewController { } }) - Preferences.General.nightModeEnabled.objectWillChange - .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateStatusBarOverlayColor() - self?.bottomBarKeyboardBackground.backgroundColor = self?.topToolbar.backgroundColor - } - .store(in: &cancellables) - Preferences.General.isUsingBottomBar.objectWillChange .receive(on: RunLoop.main) .sink { [weak self] _ in @@ -1389,7 +1384,8 @@ public class BrowserViewController: UIViewController { activeNewTabPageViewController = ntpController addChild(ntpController) - view.insertSubview(ntpController.view, belowSubview: header) + let subview = isUsingBottomBar ? header : statusBarOverlay + view.insertSubview(ntpController.view, belowSubview: subview) ntpController.didMove(toParent: self) ntpController.view.snp.makeConstraints { @@ -2323,11 +2319,7 @@ public class BrowserViewController: UIViewController { defer { setNeedsStatusBarAppearanceUpdate() } guard isUsingBottomBar, let tab = tabManager.selectedTab, tab.url.map(InternalURL.isValid) == false, let color = tab.webView?.sampledPageTopColor else { - if privateBrowsingManager.isPrivateBrowsing { - statusBarOverlay.backgroundColor = .privateModeBackground - } else { - statusBarOverlay.backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + statusBarOverlay.backgroundColor = privateBrowsingManager.browserColors.chromeBackground return } statusBarOverlay.backgroundColor = color diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+ToolbarDelegate.swift b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+ToolbarDelegate.swift index 57ee078a74b..4e75d25ec97 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+ToolbarDelegate.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController/BrowserViewController+ToolbarDelegate.swift @@ -618,6 +618,7 @@ extension BrowserViewController: TopToolbarDelegate { searchController.removeFromParent() self.searchController = nil searchLoader = nil + favoritesController?.view.isHidden = false } } @@ -631,7 +632,7 @@ extension BrowserViewController: TopToolbarDelegate { searchEngines: profile.searchEngines) // Setting up controller for SearchSuggestions - searchController = SearchViewController(with: searchDataSource) + searchController = SearchViewController(with: searchDataSource, browserColors: privateBrowsingManager.browserColors) searchController?.isUsingBottomBar = isUsingBottomBar guard let searchController = searchController else { return } searchController.setupSearchEngineList() @@ -654,11 +655,13 @@ extension BrowserViewController: TopToolbarDelegate { view.insertSubview(searchController.view, belowSubview: header) } searchController.view.snp.makeConstraints { - $0.edges.equalTo(view.safeAreaLayoutGuide) + $0.edges.equalTo(view) } searchController.didMove(toParent: self) searchController.view.setNeedsLayout() searchController.view.layoutIfNeeded() + + favoritesController?.view.isHidden = true } private func displayFavoritesController() { @@ -666,6 +669,7 @@ extension BrowserViewController: TopToolbarDelegate { let tabType = TabType.of(tabManager.selectedTab) let favoritesController = FavoritesViewController( tabType: tabType, + privateBrowsingManager: privateBrowsingManager, action: { [weak self] bookmark, action in self?.handleFavoriteAction(favorite: bookmark, action: action) }, diff --git a/Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift b/Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift index bae22c84e12..6036007db1a 100644 --- a/Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift +++ b/Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift @@ -10,6 +10,7 @@ import Preferences import BraveUI import CoreData import os.log +import Combine private class FavoritesHeaderView: UICollectionReusableView { let label = UILabel().then { @@ -90,17 +91,16 @@ class FavoritesViewController: UIViewController { private var tabType: TabType private var favoriteGridSize: CGSize = .zero private let collectionView: UICollectionView - private let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemChromeMaterial)).then { - $0.contentView.backgroundColor = UIColor.braveBackground.withAlphaComponent(0.5) - } + private let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)) private var hasPasteboardURL = false - private var isPrivateBrowsing: Bool + private var privateBrowsingManager: PrivateBrowsingManager + private var privateModeCancellable: AnyCancellable? - init(tabType: TabType, action: @escaping (Favorite, BookmarksAction) -> Void, recentSearchAction: @escaping (RecentSearch?, Bool) -> Void) { + init(tabType: TabType, privateBrowsingManager: PrivateBrowsingManager, action: @escaping (Favorite, BookmarksAction) -> Void, recentSearchAction: @escaping (RecentSearch?, Bool) -> Void) { self.tabType = tabType self.action = action self.recentSearchAction = recentSearchAction - self.isPrivateBrowsing = tabType.isPrivate + self.privateBrowsingManager = privateBrowsingManager collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) super.init(nibName: nil, bundle: nil) @@ -119,6 +119,15 @@ class FavoritesViewController: UIViewController { Preferences.Search.shouldShowRecentSearches.observe(from: self) Preferences.Search.shouldShowRecentSearchesOptIn.observe(from: self) + + privateModeCancellable = privateBrowsingManager + .$isPrivateBrowsing + .removeDuplicates() + .receive(on: RunLoop.main) + .sink(receiveValue: { [weak self] _ in + guard let self = self else { return } + self.updateColors() + }) } @available(*, unavailable) @@ -156,6 +165,7 @@ class FavoritesViewController: UIViewController { } updateUIWithSnapshot() + updateColors() } override func viewDidLayoutSubviews() { @@ -181,6 +191,12 @@ class FavoritesViewController: UIViewController { super.traitCollectionDidChange(previousTraitCollection) calculateAppropriateGrid() } + + private func updateColors() { + let browserColors = privateBrowsingManager.browserColors + // Have to apply a custom alpha here because UIVisualEffectView blurs come with their own tint + backgroundView.contentView.backgroundColor = browserColors.containerFrostedGlass.withAlphaComponent(0.8) + } private func calculateAppropriateGrid() { let width = collectionView.bounds.width - (layout.sectionInset.left + layout.sectionInset.right) - (collectionView.contentInset.left + collectionView.contentInset.right) @@ -354,7 +370,7 @@ extension FavoritesViewController: UICollectionViewDelegateFlowLayout { }) var urlChildren: [UIAction] = [openInNewTab] - if !self.isPrivateBrowsing { + if !self.privateBrowsingManager.isPrivateBrowsing { let openInNewPrivateTab = UIAction( title: Strings.openNewPrivateTabButtonTitle, handler: UIAction.deferredActionHandler { _ in @@ -670,7 +686,7 @@ extension FavoritesViewController: NSFetchedResultsControllerDelegate { cell.textLabel.text = favorite.displayTitle ?? favorite.url if let url = favorite.url?.asURL { - cell.imageView.loadFavicon(siteURL: url, isPrivateBrowsing: self.isPrivateBrowsing) + cell.imageView.loadFavicon(siteURL: url, isPrivateBrowsing: self.privateBrowsingManager.isPrivateBrowsing) } cell.accessibilityLabel = cell.textLabel.text diff --git a/Sources/Brave/Frontend/Browser/PrivacyProtection/PrivateBrowsingManager.swift b/Sources/Brave/Frontend/Browser/PrivacyProtection/PrivateBrowsingManager.swift index d5bf540fb68..dcb21c6bc9b 100644 --- a/Sources/Brave/Frontend/Browser/PrivacyProtection/PrivateBrowsingManager.swift +++ b/Sources/Brave/Frontend/Browser/PrivacyProtection/PrivateBrowsingManager.swift @@ -19,4 +19,8 @@ public final class PrivateBrowsingManager: ObservableObject { } } } + + var browserColors: any BrowserColors { + isPrivateBrowsing ? .privateMode : .standard + } } diff --git a/Sources/Brave/Frontend/Browser/ReaderModeBarView.swift b/Sources/Brave/Frontend/Browser/ReaderModeBarView.swift index ec832e09d26..e5e89366bb3 100644 --- a/Sources/Brave/Frontend/Browser/ReaderModeBarView.swift +++ b/Sources/Brave/Frontend/Browser/ReaderModeBarView.swift @@ -17,29 +17,23 @@ class ReaderModeBarView: UIView { private let readerModeButton = UIButton(type: .system).then { $0.setTitle(Strings.readerModeButtonTitle, for: .normal) - $0.setTitleColor(.braveLabel, for: .normal) $0.titleLabel?.font = .preferredFont(forTextStyle: .subheadline) $0.accessibilityIdentifier = "ReaderModeBarView.readerModeSettingsButton" } private let settingsButton = UIButton(type: .system).then { $0.setImage(UIImage(braveSystemNamed: "leo.tune"), for: .normal) - $0.tintColor = .braveLabel $0.accessibilityIdentifier = "ReaderModeBarView.settingsButton" } private var privateBrowsingManager: PrivateBrowsingManager private var cancellables: Set = [] - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - overrideUserInterfaceStyle = .dark - backgroundColor = .privateModeBackground - } else { - overrideUserInterfaceStyle = DefaultTheme( - rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride ?? .unspecified - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + private func updateColors() { + let browserColors = privateBrowsingManager.browserColors + backgroundColor = browserColors.chromeBackground + settingsButton.tintColor = browserColors.iconDefault + readerModeButton.setTitleColor(browserColors.textPrimary, for: .normal) } init(privateBrowsingManager: PrivateBrowsingManager) { @@ -70,20 +64,13 @@ class ReaderModeBarView: UIView { privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) - }) - .store(in: &cancellables) - - Preferences.General.nightModeEnabled.objectWillChange .receive(on: RunLoop.main) - .sink { [weak self] _ in - guard let self = self else { return } - self.updateColors(self.privateBrowsingManager.isPrivateBrowsing) - } + .sink(receiveValue: { [weak self] _ in + self?.updateColors() + }) .store(in: &cancellables) - updateColors(privateBrowsingManager.isPrivateBrowsing) + updateColors() } required init?(coder aDecoder: NSCoder) { diff --git a/Sources/Brave/Frontend/Browser/Search/BraveSearchPromotionCell.swift b/Sources/Brave/Frontend/Browser/Search/BraveSearchPromotionCell.swift index c29ec5093c2..c9a76d9391f 100644 --- a/Sources/Brave/Frontend/Browser/Search/BraveSearchPromotionCell.swift +++ b/Sources/Brave/Frontend/Browser/Search/BraveSearchPromotionCell.swift @@ -70,7 +70,7 @@ class BraveSearchPromotionCell: UITableViewCell { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - backgroundColor = .secondaryBraveBackground + backgroundColor = .clear selectionStyle = .none contentView.addSubview(promotionContentView) diff --git a/Sources/Brave/Frontend/Browser/Search/SearchSuggestionCell.swift b/Sources/Brave/Frontend/Browser/Search/SearchSuggestionCell.swift index 67d150fd6c5..b8a1c444ce6 100644 --- a/Sources/Brave/Frontend/Browser/Search/SearchSuggestionCell.swift +++ b/Sources/Brave/Frontend/Browser/Search/SearchSuggestionCell.swift @@ -34,7 +34,7 @@ class SuggestionCell: UITableViewCell { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - backgroundColor = .secondaryBraveBackground + backgroundColor = .clear contentView.addSubview(stackView) stackView.addArrangedSubview(titleLabel) diff --git a/Sources/Brave/Frontend/Browser/Search/SearchSuggestionsPromptView.swift b/Sources/Brave/Frontend/Browser/Search/SearchSuggestionsPromptView.swift index 4547b4f0c3b..0668efaaeef 100644 --- a/Sources/Brave/Frontend/Browser/Search/SearchSuggestionsPromptView.swift +++ b/Sources/Brave/Frontend/Browser/Search/SearchSuggestionsPromptView.swift @@ -76,7 +76,7 @@ class SearchSuggestionPromptCell: UITableViewCell { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - backgroundColor = .secondaryBraveBackground + backgroundColor = .clear contentView.addSubview(vStackView) vStackView.snp.makeConstraints { diff --git a/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift b/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift index 1017ee05499..c0216c2c642 100644 --- a/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift +++ b/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift @@ -29,11 +29,8 @@ public class SearchViewController: SiteTableViewController, LoaderListener { // MARK: SearchViewControllerUX private struct SearchViewControllerUX { - static let searchEngineScrollViewBorderColor = UIColor.black.withAlphaComponent(0.2).cgColor - static let engineButtonHeight: Float = 44 static let engineButtonWidth = engineButtonHeight * 1.4 - static let engineButtonBackgroundColor = UIColor.clear.cgColor static let searchImageWidth: Float = 24 static let searchButtonMargin: CGFloat = 8 @@ -52,7 +49,6 @@ public class SearchViewController: SiteTableViewController, LoaderListener { scrollView.showsVerticalScrollIndicator = false scrollView.showsHorizontalScrollIndicator = false scrollView.clipsToBounds = false - scrollView.backgroundColor = .braveBackground let border = UIView.separatorLine scrollView.addSubview(border) border.snp.makeConstraints { @@ -60,9 +56,8 @@ public class SearchViewController: SiteTableViewController, LoaderListener { $0.leading.trailing.equalTo(scrollView.frameLayoutGuide) } } - private let searchEngineScrollViewContent = UIView().then { - $0.backgroundColor = .braveBackground - } + private let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)) + private let searchEngineScrollViewContent = UIView() private lazy var suggestionLongPressGesture = UILongPressGestureRecognizer( target: self, @@ -77,11 +72,14 @@ public class SearchViewController: SiteTableViewController, LoaderListener { let dataSource: SearchSuggestionDataSource public static var userAgent: String? + private var browserColors: any BrowserColors // MARK: Lifecycle - init(with dataSource: SearchSuggestionDataSource) { + init(with dataSource: SearchSuggestionDataSource, browserColors: some BrowserColors) { self.dataSource = dataSource + self.browserColors = browserColors + super.init(nibName: nil, bundle: nil) dataSource.delegate = self @@ -101,22 +99,27 @@ public class SearchViewController: SiteTableViewController, LoaderListener { } override public func viewDidLoad() { - let blur = UIVisualEffectView(effect: UIBlurEffect(style: .light)) - view.addSubview(blur) - super.viewDidLoad() + + view.insertSubview(backgroundView, belowSubview: tableView) + + backgroundView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + + // Have to apply a custom alpha here because UIVisualEffectView blurs come with their own tint + backgroundView.contentView.backgroundColor = browserColors.containerFrostedGlass.withAlphaComponent(0.8) + searchEngineScrollView.backgroundColor = browserColors.containerBackground + setupSearchEngineScrollViewIfNeeded() KeyboardHelper.defaultHelper.addDelegate(self) - blur.snp.makeConstraints { make in - make.edges.equalTo(view) - } - tableView.do { $0.keyboardDismissMode = .interactive $0.separatorStyle = .none $0.sectionHeaderTopPadding = 5 + $0.backgroundColor = .clear $0.addGestureRecognizer(suggestionLongPressGesture) $0.register(SearchSuggestionPromptCell.self, forCellReuseIdentifier: SearchSuggestionPromptCell.identifier) $0.register(SuggestionCell.self, forCellReuseIdentifier: SuggestionCell.identifier) @@ -249,7 +252,7 @@ public class SearchViewController: SiteTableViewController, LoaderListener { let searchButton = UIButton() searchButton.setImage(UIImage(named: "quickSearch", in: .module, compatibleWith: nil)!.template, for: []) searchButton.imageView?.contentMode = .center - searchButton.layer.backgroundColor = SearchViewControllerUX.engineButtonBackgroundColor + searchButton.backgroundColor = .clear searchButton.addTarget(self, action: #selector(didClickSearchButton), for: .touchUpInside) searchButton.accessibilityLabel = Strings.searchSettingsButtonTitle searchButton.tintColor = .braveBlurpleTint @@ -274,7 +277,7 @@ public class SearchViewController: SiteTableViewController, LoaderListener { let engineButton = UIButton() engineButton.setImage(engine.image, for: []) engineButton.imageView?.contentMode = .scaleAspectFit - engineButton.layer.backgroundColor = SearchViewControllerUX.engineButtonBackgroundColor + engineButton.backgroundColor = .clear engineButton.addTarget(self, action: #selector(didSelectEngine), for: .touchUpInside) engineButton.accessibilityLabel = String(format: Strings.searchEngineFormatText, engine.shortName) @@ -531,9 +534,10 @@ public class SearchViewController: SiteTableViewController, LoaderListener { let cell = TwoLineTableViewCell() cell.textLabel?.text = dataSource.searchQuery cell.textLabel?.textColor = .bravePrimary - cell.imageView?.image = UIImage(named: "search_bar_find_in_page_icon", in: .module, compatibleWith: nil)! + cell.imageView?.image = UIImage(named: "search_bar_find_in_page_icon", in: .module, compatibleWith: nil)?.withRenderingMode(.alwaysTemplate) + cell.imageView?.tintColor = browserColors.iconDefault cell.imageView?.contentMode = .center - cell.backgroundColor = .secondaryBraveBackground + cell.backgroundColor = .clear return cell case .searchSuggestionsOptIn: @@ -598,7 +602,7 @@ public class SearchViewController: SiteTableViewController, LoaderListener { string: Strings.searchSuggestionOpenTabActionTitle, attributes: [ .font: DynamicFontHelper.defaultHelper.SmallSizeBoldWeightAS, - .foregroundColor: UIColor.braveLabel + .foregroundColor: browserColors.textSecondary ])) detailTextForTabSuggestions.append( @@ -606,36 +610,36 @@ public class SearchViewController: SiteTableViewController, LoaderListener { string: " · \(site.url)", attributes: [ .font: DynamicFontHelper.defaultHelper.SmallSizeRegularWeightAS, - .foregroundColor: UIColor.secondaryBraveLabel + .foregroundColor: browserColors.textSecondary ])) if let cell = cell as? TwoLineTableViewCell { - cell.textLabel?.textColor = .bravePrimary + cell.textLabel?.textColor = browserColors.textPrimary if site.siteType == .tab { cell.setLines(site.title, detailText: nil, detailAttributedText: detailTextForTabSuggestions) } else { cell.setLines(site.title, detailText: site.url) } cell.setRightBadge(site.siteType.icon?.template ?? nil) - cell.accessoryView?.tintColor = .secondaryButtonTint + cell.accessoryView?.tintColor = browserColors.iconDefault cell.imageView?.contentMode = .scaleAspectFit cell.imageView?.layer.borderColor = SearchViewControllerUX.iconBorderColor.cgColor cell.imageView?.layer.borderWidth = SearchViewControllerUX.iconBorderWidth cell.imageView?.loadFavicon(for: site.tileURL, isPrivateBrowsing: dataSource.tabType.isPrivate) - cell.backgroundColor = .secondaryBraveBackground + cell.backgroundColor = .clear } return cell case .findInPage: let cell = tableView.dequeueReusableCell(withIdentifier: "default", for: indexPath) cell.textLabel?.text = String(format: Strings.findInPageFormat, dataSource.searchQuery) - cell.textLabel?.textColor = .bravePrimary + cell.textLabel?.textColor = browserColors.textPrimary cell.textLabel?.numberOfLines = 2 cell.textLabel?.font = .systemFont(ofSize: 15.0) cell.textLabel?.lineBreakMode = .byWordWrapping cell.textLabel?.textAlignment = .left - cell.backgroundColor = .secondaryBraveBackground + cell.backgroundColor = .clear return cell } diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift index 0273eb7d4ee..b663492dd60 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift @@ -24,56 +24,39 @@ class TabBarCell: UICollectionViewCell { return button }() - private let separatorLine = UIView().then { - $0.backgroundColor = .urlBarSeparator - } + private let separatorLine = UIView() let separatorLineRight = UIView().then { - $0.backgroundColor = .urlBarSeparator $0.isHidden = true } var currentIndex: Int = -1 { didSet { isSelected = currentIndex == tabManager?.currentDisplayedIndex + separatorLine.isHidden = currentIndex == 0 } } weak var tab: Tab? weak var tabManager: TabManager? { didSet { + updateColors() privateModeCancellable = tabManager?.privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) - }) - - Preferences.General.nightModeEnabled.objectWillChange .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateColors(self?.tabManager?.privateBrowsingManager.isPrivateBrowsing == true) - } - .store(in: &cancellables) + .sink(receiveValue: { [weak self] _ in + self?.updateColors() + }) } } var closeTabCallback: ((Tab) -> Void)? private var cancellables: Set = [] - private let deselectedOverlayView = UIView().then { - $0.backgroundColor = UIColor { - if $0.userInterfaceStyle == .dark { - return UIColor.black.withAlphaComponent(0.25) - } - return UIColor.black.withAlphaComponent(0.1) - } - } - override init(frame: CGRect) { super.init(frame: frame) - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - [deselectedOverlayView, closeButton, titleLabel, separatorLine, separatorLineRight].forEach { contentView.addSubview($0) } + [closeButton, titleLabel, separatorLine, separatorLineRight].forEach { contentView.addSubview($0) } initConstraints() updateFont() @@ -81,15 +64,13 @@ class TabBarCell: UICollectionViewCell { } private var privateModeCancellable: AnyCancellable? - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - overrideUserInterfaceStyle = .dark - backgroundColor = .privateModeBackground - } else { - overrideUserInterfaceStyle = DefaultTheme( - rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride ?? .unspecified - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + private func updateColors() { + let browserColors: any BrowserColors = tabManager?.privateBrowsingManager.browserColors ?? .standard + separatorLine.backgroundColor = browserColors.dividerSubtle + separatorLineRight.backgroundColor = browserColors.dividerSubtle + backgroundColor = isSelected ? browserColors.tabBarTabActiveBackground : browserColors.tabBarTabBackground + closeButton.tintColor = browserColors.iconDefault + titleLabel.textColor = isSelected ? browserColors.textPrimary : browserColors.textSecondary } required init?(coder aDecoder: NSCoder) { @@ -97,10 +78,6 @@ class TabBarCell: UICollectionViewCell { } private func initConstraints() { - deselectedOverlayView.snp.makeConstraints { - $0.edges.equalToSuperview() - } - titleLabel.snp.makeConstraints { make in make.top.bottom.equalTo(self) make.left.equalTo(self).inset(16) @@ -136,21 +113,16 @@ class TabBarCell: UICollectionViewCell { func configure() { if isSelected { - titleLabel.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.semibold) titleLabel.alpha = 1.0 - titleLabel.textColor = .bravePrimary closeButton.isHidden = false - deselectedOverlayView.isHidden = true } // Prevent swipe and release outside- deselects cell. else if currentIndex != tabManager?.currentDisplayedIndex { - titleLabel.font = UIFont.systemFont(ofSize: 12) titleLabel.alpha = 0.8 - titleLabel.textColor = .braveLabel closeButton.isHidden = true - deselectedOverlayView.isHidden = false } updateFont() + updateColors() } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabsBarViewController.swift b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabsBarViewController.swift index 6615add704a..8cc94a4e092 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabsBarViewController.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabsBarViewController.swift @@ -68,7 +68,6 @@ class TabsBarViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground collectionView.backgroundColor = view.backgroundColor collectionView.dragDelegate = UIApplication.shared.supportsMultipleScenes ? self : nil collectionView.dropDelegate = UIApplication.shared.supportsMultipleScenes ? self : nil @@ -132,20 +131,16 @@ class TabsBarViewController: UIViewController { self.delegate?.tabsBarDidSelectAddNewWindow(true) })) + updateColors() + plusButton.menu = UIMenu(title: "", identifier: nil, children: newTabMenu) privateModeCancellable = tabManager?.privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() + .receive(on: RunLoop.main) .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) + self?.updateColors() }) - - Preferences.General.nightModeEnabled.objectWillChange - .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateColors(self?.tabManager?.privateBrowsingManager.isPrivateBrowsing == true) - } - .store(in: &cancellables) } override func viewDidAppear(_ animated: Bool) { @@ -155,14 +150,9 @@ class TabsBarViewController: UIViewController { } private var privateModeCancellable: AnyCancellable? - private func updateColors(_ isPrivateBrowsing: Bool) { - let backgroundColor: UIColor - if isPrivateBrowsing { - backgroundColor = .privateModeBackground - } else { - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } - view.backgroundColor = backgroundColor + private func updateColors() { + let browserColors: any BrowserColors = tabManager?.privateBrowsingManager.browserColors ?? .standard + view.backgroundColor = browserColors.chromeBackground collectionView.backgroundColor = view.backgroundColor } diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController+TableViewDelegate.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController+TableViewDelegate.swift index 19c053f2dac..86c9001df03 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController+TableViewDelegate.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController+TableViewDelegate.swift @@ -79,7 +79,8 @@ extension TabTrayController: UITableViewDataSource, UITableViewDelegate { } let headerView = tableView.dequeueReusableHeaderFooter() as TabSyncHeaderView - + let browserColors: some BrowserColors = .standard // Sync devices dont appear in private mode + headerView.do { $0.imageIconView.image = deviceTypeImage?.template $0.titleLabel.text = sectionDetails.name @@ -89,8 +90,8 @@ extension TabTrayController: UITableViewDataSource, UITableViewDelegate { $0.isCollapsed = hiddenSections.contains(section) $0.section = section $0.delegate = self - $0.backgroundColor = .secondaryBraveBackground - $0.tintColor = .secondaryBraveBackground + $0.backgroundColor = browserColors.chromeBackground + $0.tintColor = browserColors.chromeBackground } return headerView diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift index 2fd5b819ba4..37b615ffd9d 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift @@ -109,19 +109,14 @@ class TabTrayController: AuthenticationController { static let segmentedControlTopInset = 16.0 } - private let containerView = UIView().then { - $0.backgroundColor = .secondaryBraveBackground - } + private let containerView = UIView() - private let tabContentView = UIView().then { - $0.backgroundColor = .braveBackground - } + private let tabContentView = UIView() private var tabTypeSelectorItems = [UIImage]() private lazy var tabTypeSelector: UISegmentedControl = { let segmentedControl = UISegmentedControl(items: tabTypeSelectorItems).then { $0.selectedSegmentIndex = 0 - $0.backgroundColor = .secondaryBraveBackground $0.addTarget(self, action: #selector(typeSelectionDidChange(_:)), for: .valueChanged) } return segmentedControl @@ -139,7 +134,6 @@ class TabTrayController: AuthenticationController { $0.setImage(UIImage(named: "add_tab", in: .module, compatibleWith: nil)!.template, for: .normal) $0.accessibilityLabel = Strings.tabTrayAddTabAccessibilityLabel $0.accessibilityIdentifier = "TabTrayController.addTabButton" - $0.tintColor = .braveLabel $0.contentEdgeInsets = .init(top: 0, left: UX.buttonEdgeInset, bottom: 0, right: UX.buttonEdgeInset) $0.setContentCompressionResistancePriority(.required, for: .horizontal) } @@ -152,7 +146,6 @@ class TabTrayController: AuthenticationController { $0.titleLabel?.adjustsFontSizeToFitWidth = true $0.accessibilityLabel = Strings.done $0.accessibilityIdentifier = "TabTrayController.doneButton" - $0.tintColor = .braveLabel } let privateModeButton = SelectedInsetButton().then { @@ -164,6 +157,7 @@ class TabTrayController: AuthenticationController { $0.accessibilityLabel = Strings.done $0.accessibilityIdentifier = "TabTrayController.privateButton" $0.tintColor = .braveLabel + $0.selectedBackgroundColor = UIColor(braveSystemName: .primitivePrivateWindow70) if Preferences.Privacy.privateBrowsingOnly.value { $0.alpha = 0 @@ -301,8 +295,9 @@ class TabTrayController: AuthenticationController { privateModeCancellable = tabManager.privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) + .receive(on: RunLoop.main) + .sink(receiveValue: { [weak self] _ in + self?.updateColors() }) windowProtection?.cancelPressed @@ -319,6 +314,7 @@ class TabTrayController: AuthenticationController { }.store(in: &localAuthObservers) reloadOpenTabsSession() + updateColors() becomeFirstResponder() } @@ -393,13 +389,40 @@ class TabTrayController: AuthenticationController { } } - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - overrideUserInterfaceStyle = .dark - } else { - overrideUserInterfaceStyle = DefaultTheme( - rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride ?? .unspecified - } + private func updateColors() { + let privateBrowsingManager = tabManager.privateBrowsingManager + let browserColors = privateBrowsingManager.browserColors + containerView.backgroundColor = browserColors.chromeBackground + tabTypeSelector.backgroundColor = browserColors.chromeBackground + newTabButton.tintColor = browserColors.iconDefault + privateModeButton.setTitleColor(browserColors.textSecondary, for: .normal) + privateModeButton.setTitleColor(browserColors.textPrimary, for: .selected) + + let toolbarAppearance = UIToolbarAppearance() + toolbarAppearance.configureWithOpaqueBackground() + toolbarAppearance.backgroundColor = browserColors.chromeBackground + toolbarAppearance.backgroundEffect = nil + navigationController?.toolbar.do { + $0.tintColor = browserColors.textSecondary + $0.standardAppearance = toolbarAppearance + $0.compactAppearance = toolbarAppearance + $0.scrollEdgeAppearance = toolbarAppearance + } + + let navBarAppearance = UINavigationBarAppearance() + navBarAppearance.configureWithOpaqueBackground() + navBarAppearance.backgroundColor = browserColors.chromeBackground + navBarAppearance.backgroundEffect = nil + navigationController?.navigationBar.do { + $0.tintColor = browserColors.textSecondary + $0.standardAppearance = navBarAppearance + $0.compactAppearance = navBarAppearance + $0.scrollEdgeAppearance = navBarAppearance + } + + // Need to force a relayout for the nav controller for the appearance to take affect + navigationController?.view.setNeedsLayout() + navigationController?.view.layoutIfNeeded() setNeedsStatusBarAppearanceUpdate() } diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift index 6dd763a7e62..f1dd89e726e 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift @@ -28,7 +28,7 @@ extension TabTrayController { override init(frame: CGRect) { super.init(frame: frame) - backgroundColor = .braveBackground + backgroundColor = .clear addSubview(tableView) tableView.snp.makeConstraints { make in @@ -38,7 +38,7 @@ extension TabTrayController { tableView.do { $0.register(TabSyncTableViewCell.self) $0.registerHeaderFooter(TabSyncHeaderView.self) - $0.backgroundColor = .secondaryBraveBackground + $0.backgroundColor = .clear $0.estimatedRowHeight = SiteTableViewControllerUX.rowHeight $0.estimatedSectionHeaderHeight = SiteTableViewControllerUX.rowHeight $0.separatorColor = .braveSeparator diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayContainerView.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayContainerView.swift index 1e5c7c97d73..2064c8e7777 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayContainerView.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayContainerView.swift @@ -45,7 +45,7 @@ extension TabTrayController { lazy var collectionView = UICollectionView(frame: .zero, collectionViewLayout: generateLayout(numberOfColumns: numberOfColumns)).then { $0.setContentHuggingPriority(.defaultLow, for: .vertical) - $0.backgroundColor = .secondaryBraveBackground + $0.backgroundColor = .clear $0.register(TabCell.self, forCellWithReuseIdentifier: TabCell.identifier) } @@ -60,7 +60,6 @@ extension TabTrayController { override init(frame: CGRect) { super.init(frame: frame) - backgroundColor = .braveBackground accessibilityLabel = Strings.tabTrayAccessibilityLabel let stackView = UIStackView().then { diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayPrivateModeInfoView.swift b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayPrivateModeInfoView.swift index f42ea764878..f889f5f165c 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayPrivateModeInfoView.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayPrivateModeInfoView.swift @@ -73,8 +73,6 @@ extension TabTrayController { override init(frame: CGRect) { super.init(frame: frame) - backgroundColor = .secondaryBraveBackground - addSubview(scrollView) scrollView.addSubview(stackView) stackView.addArrangedSubview(iconImageView) diff --git a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift index 60a8b12a9c5..d0689d11a10 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift @@ -35,7 +35,7 @@ class BottomToolbarView: UIView, ToolbarProtocol { super.init(frame: .zero) setupAccessibility() - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground + backgroundColor = privateBrowsingManager.browserColors.chromeBackground addSubview(contentView) addSubview(line) @@ -54,30 +54,21 @@ class BottomToolbarView: UIView, ToolbarProtocol { privateModeCancellable = privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() + .receive(on: RunLoop.main) .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) + guard let self = self else { return } + self.updateColors() + self.helper?.updateForTraitCollection(self.traitCollection, browserColors: privateBrowsingManager.browserColors) }) - Preferences.General.nightModeEnabled.objectWillChange - .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateColors(privateBrowsingManager.isPrivateBrowsing) - } - .store(in: &cancellables) + helper?.updateForTraitCollection(traitCollection, browserColors: privateBrowsingManager.browserColors) - helper?.updateForTraitCollection(traitCollection) + updateColors() } private var privateModeCancellable: AnyCancellable? - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - overrideUserInterfaceStyle = .dark - backgroundColor = .privateModeBackground - } else { - overrideUserInterfaceStyle = DefaultTheme( - rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride ?? .unspecified - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + private func updateColors() { + backgroundColor = privateBrowsingManager.browserColors.chromeBackground } private var isSearchButtonEnabled: Bool = false { @@ -105,7 +96,7 @@ class BottomToolbarView: UIView, ToolbarProtocol { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - helper?.updateForTraitCollection(traitCollection) + helper?.updateForTraitCollection(traitCollection, browserColors: privateBrowsingManager.browserColors) } private func setupAccessibility() { diff --git a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/EmptyStateOverlayView.swift b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/EmptyStateOverlayView.swift index 2561932e53c..45fe82357e7 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/EmptyStateOverlayView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/EmptyStateOverlayView.swift @@ -109,8 +109,6 @@ class EmptyStateOverlayView: UIView { } private func doLayout(details: EmptyOverlayStateDetails) { - backgroundColor = .secondaryBraveBackground - let heightOffset = traitCollection.verticalSizeClass == .compact ? 0 : -50 addSubview(containerView) diff --git a/Sources/Brave/Frontend/Browser/Toolbars/HeaderContainerView.swift b/Sources/Brave/Frontend/Browser/Toolbars/HeaderContainerView.swift index 10f0d5929c7..a03493ae81c 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/HeaderContainerView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/HeaderContainerView.swift @@ -23,16 +23,17 @@ class HeaderContainerView: UIView { updateConstraints() } } - let line = UIView().then { - $0.backgroundColor = .urlBarSeparator - } + let line = UIView() /// Container view for both the expanded & collapsed variants of the bar let contentView = UIView() private var cancellables: Set = [] + private let privateBrowsingManager: PrivateBrowsingManager init(privateBrowsingManager: PrivateBrowsingManager) { + self.privateBrowsingManager = privateBrowsingManager + super.init(frame: .zero) addSubview(contentView) @@ -51,19 +52,15 @@ class HeaderContainerView: UIView { $0.edges.equalToSuperview() } + updateColors() + privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) - }) - .store(in: &cancellables) - - Preferences.General.nightModeEnabled.objectWillChange .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateColors(privateBrowsingManager.isPrivateBrowsing) - } + .sink(receiveValue: { [weak self] _ in + self?.updateColors() + }) .store(in: &cancellables) } @@ -89,12 +86,10 @@ class HeaderContainerView: UIView { } } - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - backgroundColor = .privateModeBackground - } else { - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + private func updateColors() { + let browserColors = privateBrowsingManager.browserColors + line.backgroundColor = browserColors.dividerSubtle + backgroundColor = browserColors.chromeBackground } @available(*, unavailable) diff --git a/Sources/Brave/Frontend/Browser/Toolbars/ToolbarButton.swift b/Sources/Brave/Frontend/Browser/Toolbars/ToolbarButton.swift index a2286e86fac..5188f58409a 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/ToolbarButton.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/ToolbarButton.swift @@ -18,38 +18,42 @@ extension UITraitCollection { } class ToolbarButton: UIButton { - fileprivate var selectedTintColor: UIColor? - fileprivate var primaryTintColor: UIColor? - fileprivate var disabledTintColor: UIColor? + var selectedTintColor: UIColor? { + didSet { + updateTintColor() + } + } + var primaryTintColor: UIColor? { + didSet { + updateTintColor() + } + } + var disabledTintColor: UIColor? { + didSet { + updateTintColor() + } + } - required init() { + init() { super.init(frame: .zero) adjustsImageWhenHighlighted = false imageView?.contentMode = .scaleAspectFit - - selectedTintColor = .braveBlurpleTint - primaryTintColor = .braveLabel - tintColor = primaryTintColor - imageView?.tintColor = tintColor } - - override init(frame: CGRect) { - fatalError("init(coder:) has not been implemented") - } - - required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") + + @available(*, unavailable) + required init(coder: NSCoder) { + fatalError() } override open var isHighlighted: Bool { didSet { - self.tintColor = isHighlighted ? selectedTintColor : primaryTintColor + updateTintColor() } } override open var isEnabled: Bool { didSet { - self.tintColor = primaryTintColor?.withAlphaComponent(isEnabled ? 1.0 : 0.4) + updateTintColor() } } @@ -58,6 +62,23 @@ class ToolbarButton: UIButton { self.imageView?.tintColor = self.tintColor } } + + private func updateTintColor() { + let tintColor: UIColor? = { + if !isEnabled { + if let disabledTintColor { + return disabledTintColor + } else { + return primaryTintColor?.withAlphaComponent(0.4) + } + } + if isHighlighted { + return selectedTintColor + } + return primaryTintColor + }() + self.tintColor = tintColor + } override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willDisplayMenuFor configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) { UIImpactFeedbackGenerator(style: .medium).bzzt() diff --git a/Sources/Brave/Frontend/Browser/Toolbars/ToolbarHelper.swift b/Sources/Brave/Frontend/Browser/Toolbars/ToolbarHelper.swift index b58a634d393..35e8845710c 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/ToolbarHelper.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/ToolbarHelper.swift @@ -85,7 +85,7 @@ class ToolbarHelper: NSObject { toolbar.tabToolbarDelegate?.tabToolbarDidPressSearch(toolbar, button: toolbar.searchButton) } - func updateForTraitCollection(_ traitCollection: UITraitCollection, additionalButtons: [UIButton] = []) { + func updateForTraitCollection(_ traitCollection: UITraitCollection, browserColors: some BrowserColors, additionalButtons: [UIButton] = []) { let toolbarTraitCollection = UITraitCollection(preferredContentSizeCategory: traitCollection.toolbarButtonContentSizeCategory) let config = UIImage.SymbolConfiguration(pointSize: UIFont.preferredFont(forTextStyle: .body, compatibleWith: toolbarTraitCollection).pointSize, weight: .regular, scale: .large) let buttons: [UIButton] = [ @@ -97,6 +97,13 @@ class ToolbarHelper: NSObject { ] + additionalButtons for button in buttons { button.setPreferredSymbolConfiguration(config, forImageIn: .normal) + button.tintColor = browserColors.iconDefault + if let button = button as? ToolbarButton { + button.primaryTintColor = browserColors.iconDefault + button.selectedTintColor = browserColors.iconActive + button.disabledTintColor = browserColors.iconDisabled + } } + toolbar.tabsButton.browserColors = browserColors } } diff --git a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift index 45956c1b73d..79df78221f9 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/CollapsedURLBarView.swift @@ -36,6 +36,12 @@ class CollapsedURLBarView: UIView { $0.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) } + var browserColors: any BrowserColors = .standard { + didSet { + updateForTraitCollectionAndBrowserColors() + } + } + var isUsingBottomBar: Bool = false { didSet { setNeedsUpdateConstraints() @@ -101,15 +107,15 @@ class CollapsedURLBarView: UIView { $0.centerX.equalToSuperview() } - updateForTraitCollection() + updateForTraitCollectionAndBrowserColors() } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - updateForTraitCollection() + updateForTraitCollectionAndBrowserColors() } - private func updateForTraitCollection() { + private func updateForTraitCollectionAndBrowserColors() { let clampedTraitCollection = traitCollection.clampingSizeCategory(maximum: .accessibilityLarge) lockImageView.setPreferredSymbolConfiguration( .init( @@ -122,6 +128,8 @@ class CollapsedURLBarView: UIView { forImageIn: .normal ) urlLabel.font = .preferredFont(forTextStyle: .caption1, compatibleWith: clampedTraitCollection) + lockImageView.tintColor = browserColors.iconDefault + urlLabel.textColor = browserColors.textPrimary } override func updateConstraints() { diff --git a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift index 96ea8391a40..37a9d18ecd1 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TabLocationView.swift @@ -113,9 +113,9 @@ class TabLocationView: UIView { } } - lazy var placeholder: NSAttributedString = { - return NSAttributedString(string: Strings.tabToolbarSearchAddressPlaceholderText, attributes: [NSAttributedString.Key.foregroundColor: UIColor.secondaryBraveLabel]) - }() + func makePlaceholder(colors: some BrowserColors) -> NSAttributedString { + NSAttributedString(string: Strings.tabToolbarSearchAddressPlaceholderText, attributes: [NSAttributedString.Key.foregroundColor: colors.textSecondary]) + } lazy var urlTextField: UITextField = { let urlTextField = DisplayTextField() @@ -123,12 +123,11 @@ class TabLocationView: UIView { // Prevent the field from compressing the toolbar buttons on the 4S in landscape. urlTextField.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 250), for: .horizontal) urlTextField.setContentCompressionResistancePriority(.required, for: .vertical) - urlTextField.attributedPlaceholder = self.placeholder + urlTextField.attributedPlaceholder = makePlaceholder(colors: .standard) urlTextField.accessibilityIdentifier = "url" urlTextField.font = .preferredFont(forTextStyle: .body) urlTextField.backgroundColor = .clear urlTextField.clipsToBounds = true - urlTextField.textColor = .braveLabel urlTextField.isEnabled = false urlTextField.defaultTextAttributes = { var attributes = urlTextField.defaultTextAttributes @@ -147,9 +146,8 @@ class TabLocationView: UIView { }() private(set) lazy var lockImageView = ToolbarButton().then { - $0.setImage(UIImage(braveSystemNamed: "brave.lock.alt", compatibleWith: nil), for: .normal) + $0.setImage(UIImage(braveSystemNamed: "brave.lock.alt", compatibleWith: nil)?.withRenderingMode(.alwaysTemplate), for: .normal) $0.isHidden = true - $0.tintColor = .braveLabel $0.isAccessibilityElement = true $0.imageView?.contentMode = .center $0.contentHorizontalAlignment = .center @@ -166,8 +164,6 @@ class TabLocationView: UIView { readerModeButton.imageView?.contentMode = .scaleAspectFit readerModeButton.accessibilityLabel = Strings.tabToolbarReaderViewButtonAccessibilityLabel readerModeButton.accessibilityIdentifier = "TabLocationView.readerModeButton" - readerModeButton.unselectedTintColor = .braveLabel - readerModeButton.selectedTintColor = .braveBlurpleTint return readerModeButton }() @@ -224,7 +220,6 @@ class TabLocationView: UIView { lazy var separatorLine: UIView = CustomSeparatorView(lineSize: .init(width: 1, height: 26), cornerRadius: 2).then { $0.isUserInteractionEnabled = false - $0.backgroundColor = .braveSeparator $0.layoutMargins = UIEdgeInsets(top: 0, left: 2, bottom: 0, right: 2) } @@ -236,14 +231,14 @@ class TabLocationView: UIView { } private var isVoiceSearchAvailable: Bool + private let privateBrowsingManager: PrivateBrowsingManager init(voiceSearchSupported: Bool, privateBrowsingManager: PrivateBrowsingManager) { + self.privateBrowsingManager = privateBrowsingManager isVoiceSearchAvailable = voiceSearchSupported super.init(frame: .zero) - backgroundColor = .braveBackground - tabObservers = registerFor(.didChangeContentBlocking, .didGainFocus, queue: .main) addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapLocationBar))) @@ -287,8 +282,9 @@ class TabLocationView: UIView { privateModeCancellable = privateBrowsingManager.$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) + .receive(on: RunLoop.main) + .sink(receiveValue: { [weak self] _ in + self?.updateColors() }) playlistButton.menuActionHandler = { [unowned self] action in @@ -296,6 +292,8 @@ class TabLocationView: UIView { } updateForTraitCollection() + + updateColors() } required init(coder: NSCoder) { @@ -339,14 +337,18 @@ class TabLocationView: UIView { } } - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - overrideUserInterfaceStyle = .dark - backgroundColor = .braveBackground.resolvedColor(with: .init(userInterfaceStyle: .dark)) - } else { - overrideUserInterfaceStyle = DefaultTheme( - rawValue: Preferences.General.themeNormalMode.value)?.userInterfaceStyleOverride ?? .unspecified - backgroundColor = .braveBackground + private func updateColors() { + let browserColors = privateBrowsingManager.browserColors + backgroundColor = browserColors.containerBackground + urlTextField.textColor = browserColors.textPrimary + urlTextField.attributedPlaceholder = makePlaceholder(colors: browserColors) + separatorLine.backgroundColor = browserColors.dividerSubtle + readerModeButton.unselectedTintColor = browserColors.iconDefault + readerModeButton.selectedTintColor = browserColors.iconActive + for button in [reloadButton, lockImageView, voiceSearchButton] { + button.primaryTintColor = browserColors.iconDefault + button.disabledTintColor = browserColors.iconDisabled + button.selectedTintColor = browserColors.iconActive } } diff --git a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift index d7bea065df6..b6c2fbf8258 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift @@ -246,8 +246,6 @@ class TopToolbarView: UIView, ToolbarProtocol { self.privateBrowsingManager = privateBrowsingManager super.init(frame: .zero) - - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground locationContainer.addSubview(locationView) @@ -289,23 +287,19 @@ class TopToolbarView: UIView, ToolbarProtocol { // Make sure we hide any views that shouldn't be showing in non-overlay mode. updateViewsForOverlayModeAndToolbarChanges() - + privateModeCancellable = privateBrowsingManager .$isPrivateBrowsing .removeDuplicates() - .sink(receiveValue: { [weak self] isPrivateBrowsing in - self?.updateColors(isPrivateBrowsing) - }) - - Preferences.General.nightModeEnabled.objectWillChange .receive(on: RunLoop.main) - .sink { [weak self] _ in - self?.updateColors(privateBrowsingManager.isPrivateBrowsing) - } - .store(in: &cancellables) + .sink(receiveValue: { [weak self] _ in + guard let self = self else { return } + self.updateColors() + self.helper?.updateForTraitCollection(self.traitCollection, browserColors: privateBrowsingManager.browserColors) + }) updateURLBarButtonsVisibility() - helper?.updateForTraitCollection(traitCollection, additionalButtons: [bookmarkButton]) + helper?.updateForTraitCollection(traitCollection, browserColors: privateBrowsingManager.browserColors, additionalButtons: [bookmarkButton]) updateForTraitCollection() let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(swipedLocationView)) @@ -317,6 +311,8 @@ class TopToolbarView: UIView, ToolbarProtocol { qrCodeButton.addTarget(self, action: #selector(topToolbarDidPressQrCodeButton), for: .touchUpInside) voiceSearchButton.addTarget(self, action: #selector(topToolbarDidPressVoiceSearchButton), for: .touchUpInside) + + updateColors() } @available(*, unavailable) @@ -326,7 +322,7 @@ class TopToolbarView: UIView, ToolbarProtocol { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - helper?.updateForTraitCollection(traitCollection, additionalButtons: [bookmarkButton]) + helper?.updateForTraitCollection(traitCollection, browserColors: privateBrowsingManager.browserColors, additionalButtons: [bookmarkButton]) updateForTraitCollection() } @@ -381,12 +377,12 @@ class TopToolbarView: UIView, ToolbarProtocol { return self.locationTextField?.becomeFirstResponder() ?? false } - private func updateColors(_ isPrivateBrowsing: Bool) { - if isPrivateBrowsing { - backgroundColor = .privateModeBackground - } else { - backgroundColor = Preferences.General.nightModeEnabled.value ? .nightModeBackground : .urlBarBackground - } + private func updateColors() { + let browserColors = privateBrowsingManager.browserColors + backgroundColor = browserColors.chromeBackground + locationTextField?.backgroundColor = browserColors.containerBackground + locationTextField?.textColor = browserColors.textPrimary + locationTextField?.attributedPlaceholder = locationView.makePlaceholder(colors: browserColors) } /// Created whenever the location bar on top is selected @@ -399,7 +395,8 @@ class TopToolbarView: UIView, ToolbarProtocol { guard let locationTextField = locationTextField else { return } locationTextField.do { - $0.backgroundColor = .braveBackground + $0.backgroundColor = privateBrowsingManager.browserColors.containerBackground + $0.textColor = privateBrowsingManager.browserColors.textPrimary $0.translatesAutoresizingMaskIntoConstraints = false $0.autocompleteDelegate = self $0.keyboardType = .webSearch @@ -412,7 +409,7 @@ class TopToolbarView: UIView, ToolbarProtocol { $0.font = .preferredFont(forTextStyle: .body) $0.accessibilityIdentifier = "address" $0.accessibilityLabel = Strings.URLBarViewLocationTextViewAccessibilityLabel - $0.attributedPlaceholder = self.locationView.placeholder + $0.attributedPlaceholder = self.locationView.makePlaceholder(colors: .standard) $0.clearButtonMode = .whileEditing $0.rightViewMode = .never } diff --git a/Sources/Brave/Frontend/Widgets/TabsButton.swift b/Sources/Brave/Frontend/Widgets/TabsButton.swift index 76f21ba6485..11a5dad567f 100644 --- a/Sources/Brave/Frontend/Widgets/TabsButton.swift +++ b/Sources/Brave/Frontend/Widgets/TabsButton.swift @@ -17,7 +17,6 @@ class TabsButton: UIButton { private let countLabel = UILabel().then { $0.textAlignment = .center $0.isUserInteractionEnabled = false - $0.textColor = .braveLabel } private let borderView = UIView().then { @@ -26,6 +25,12 @@ class TabsButton: UIButton { $0.layer.cornerCurve = .continuous $0.isUserInteractionEnabled = false } + + var browserColors: any BrowserColors = .standard { + didSet { + updateForTraitCollectionAndBrowserColors() + } + } override init(frame: CGRect) { super.init(frame: frame) @@ -40,7 +45,7 @@ class TabsButton: UIButton { countLabel.snp.makeConstraints { $0.edges.equalToSuperview() } - updateForTraitCollection() + updateForTraitCollectionAndBrowserColors() } @available(*, unavailable) @@ -50,7 +55,7 @@ class TabsButton: UIButton { override var isHighlighted: Bool { didSet { - let color: UIColor = isHighlighted ? .braveBlurpleTint : .braveLabel + let color: UIColor = isHighlighted ? browserColors.iconActive : browserColors.iconDefault countLabel.textColor = color borderView.layer.borderColor = color.resolvedColor(with: traitCollection).cgColor } @@ -58,12 +63,13 @@ class TabsButton: UIButton { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - updateForTraitCollection() + updateForTraitCollectionAndBrowserColors() } - private func updateForTraitCollection() { + private func updateForTraitCollectionAndBrowserColors() { // CGColor's do not get automatic updates - borderView.layer.borderColor = isHighlighted ? UIColor.braveBlurpleTint.cgColor : UIColor.braveLabel.resolvedColor(with: traitCollection).cgColor + countLabel.textColor = isHighlighted ? browserColors.iconActive : browserColors.iconDefault + borderView.layer.borderColor = isHighlighted ? browserColors.iconActive.cgColor : browserColors.iconDefault.resolvedColor(with: traitCollection).cgColor let toolbarTraitCollection = UITraitCollection(preferredContentSizeCategory: traitCollection.toolbarButtonContentSizeCategory) let metrics = UIFontMetrics(forTextStyle: .body) diff --git a/Sources/BraveUI/Buttons/InsetButton.swift b/Sources/BraveUI/Buttons/InsetButton.swift index f1783417287..21ce1a88bdd 100644 --- a/Sources/BraveUI/Buttons/InsetButton.swift +++ b/Sources/BraveUI/Buttons/InsetButton.swift @@ -47,7 +47,7 @@ public class SelectedInsetButton: InsetButton { } } - var selectedBackgroundColor: UIColor? { + public var selectedBackgroundColor: UIColor? { didSet { if isSelected { backgroundColor = selectedBackgroundColor diff --git a/Sources/DesignSystem/Colors/LegacyColors.swift b/Sources/DesignSystem/Colors/LegacyColors.swift index a8b8b2f28fb..7cb1a6b3504 100644 --- a/Sources/DesignSystem/Colors/LegacyColors.swift +++ b/Sources/DesignSystem/Colors/LegacyColors.swift @@ -168,37 +168,9 @@ extension UIColor { } } -extension UIColor { - public static var urlBarBackground: UIColor { - .init { traitCollection in - if traitCollection.userInterfaceStyle == .dark { - return .tertiaryBraveBackground - } - return .secondaryBraveBackground - } - } - public static var urlBarSeparator: UIColor { - .init { traitCollection in - if traitCollection.userInterfaceStyle == .dark { - return UIColor(white: 1.0, alpha: 0.1) - } - return .braveSeparator - } - } - public static var nightModeBackground: UIColor { - return .secondaryBraveBackground - } -} - // MARK: - Static Colors extension UIColor { - public static var privateModeBackground: UIColor { - .init(hex: 0x2C2153) - } - public static var secondaryPrivateModeBackground: UIColor { - .init(hex: 0x0D0920) - } public static var statsAdsBlockedTint: UIColor { .braveOrange }