From 3e1373c1b3c11de137e46de9a73a22206a77d06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=C2=A0Buczek?= Date: Mon, 21 Oct 2019 18:38:34 +0200 Subject: [PATCH] Fix #1525: Themable 'find in page' bar. --- BraveShared/AppearanceAttributes.swift | 5 +++++ .../Browser/BrowserViewController.swift | 1 + Client/Frontend/Browser/FindInPageBar.swift | 21 +++++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/BraveShared/AppearanceAttributes.swift b/BraveShared/AppearanceAttributes.swift index e59368728..3bbd0721a 100644 --- a/BraveShared/AppearanceAttributes.swift +++ b/BraveShared/AppearanceAttributes.swift @@ -73,4 +73,9 @@ public extension UIButton { if #available(iOS 13.0, *) { } else { titleLabel?.appearanceTextColor = newValue } } } + + @objc dynamic var appearanceTintColor: UIColor! { + get { return self.tintColor } + set { self.tintColor = newValue } + } } diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 70f1d07b0..cc2baa8e8 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -1365,6 +1365,7 @@ class BrowserViewController: UIViewController { self.findInPageBar = findInPageBar findInPageBar.delegate = self alertStackView.addArrangedSubview(findInPageBar) + findInPageBar.applyTheme(Theme.of(tabManager.selectedTab)) findInPageBar.snp.makeConstraints { make in make.height.equalTo(UIConstants.ToolbarHeight) diff --git a/Client/Frontend/Browser/FindInPageBar.swift b/Client/Frontend/Browser/FindInPageBar.swift index f622b675f..c06c7859c 100644 --- a/Client/Frontend/Browser/FindInPageBar.swift +++ b/Client/Frontend/Browser/FindInPageBar.swift @@ -27,6 +27,7 @@ class FindInPageBar: UIView { fileprivate let matchCountView = UILabel() fileprivate let previousButton = UIButton() fileprivate let nextButton = UIButton() + fileprivate let closeButton = UIButton() var currentResult = 0 { didSet { @@ -84,22 +85,21 @@ class FindInPageBar: UIView { matchCountView.accessibilityIdentifier = "FindInPage.matchCount" addSubview(matchCountView) - previousButton.setImage(#imageLiteral(resourceName: "find_previous"), for: []) + previousButton.setImage(#imageLiteral(resourceName: "find_previous").template, for: []) previousButton.setTitleColor(FindInPageUX.ButtonColor, for: []) previousButton.accessibilityLabel = Strings.FindInPagePreviousResultButtonAccessibilityLabel previousButton.addTarget(self, action: #selector(didFindPrevious), for: .touchUpInside) previousButton.accessibilityIdentifier = "FindInPage.find_previous" addSubview(previousButton) - nextButton.setImage(#imageLiteral(resourceName: "find_next"), for: []) + nextButton.setImage(#imageLiteral(resourceName: "find_next").template, for: []) nextButton.setTitleColor(FindInPageUX.ButtonColor, for: []) nextButton.accessibilityLabel = Strings.FindInPageNextResultButtonAccessibilityLabel nextButton.addTarget(self, action: #selector(didFindNext), for: .touchUpInside) nextButton.accessibilityIdentifier = "FindInPage.find_next" addSubview(nextButton) - let closeButton = UIButton() - closeButton.setImage(#imageLiteral(resourceName: "find_close"), for: []) + closeButton.setImage(#imageLiteral(resourceName: "find_close").template, for: []) closeButton.setTitleColor(FindInPageUX.ButtonColor, for: []) closeButton.accessibilityLabel = Strings.FindInPageDoneButtonAccessibilityLabel closeButton.addTarget(self, action: #selector(didPressClose), for: .touchUpInside) @@ -173,3 +173,16 @@ class FindInPageBar: UIView { delegate?.findInPageDidPressClose(self) } } + +extension FindInPageBar: Themeable { + func applyTheme(_ theme: Theme) { + styleChildren(theme: theme) + + appearanceBackgroundColor = theme.colors.home + searchText.appearanceTextColor = theme.colors.tints.home + + [nextButton, previousButton, closeButton].forEach { + $0.appearanceTintColor = theme.colors.tints.home + } + } +}