Skip to content

Commit

Permalink
[iOS] Improve toolbar icon sizing
Browse files Browse the repository at this point in the history
This change also replaces the coloured product icons so that they include proper visual spacing built-in
  • Loading branch information
kylehickinson committed Oct 4, 2024
1 parent e8cfe88 commit d07147e
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class BackForwardTableViewCell: UITableViewCell {
if let s = site {
if InternalURL.isValid(url: s.tileURL) {
faviconView.backgroundColor = .white
faviconView.image = UIImage(sharedNamed: "brave.logo")?.imageWithInsets(
insets: .init(equalInset: 4)
)
faviconView.image = UIImage(sharedNamed: "brave.logo")
} else {
faviconView.loadFavicon(for: s.tileURL, isPrivateBrowsing: isPrivateBrowsing)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ public class BrowserViewController: UIViewController {
) {
let showToolbar = shouldShowFooterForTraitCollection(newCollection)
bottomTouchArea.isEnabled = showToolbar
topToolbar.setShowToolbar(!showToolbar)
topToolbar.setShowToolbar(showToolbar)

if (showToolbar && toolbar == nil) || (!showToolbar && toolbar != nil) {
toolbar?.removeFromSuperview()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ class BottomToolbarView: UIView, ToolbarProtocol {
self.updateColors()
self.helper?.updateForTraitCollection(
self.traitCollection,
browserColors: privateBrowsingManager.browserColors
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: true
)
})

helper?.updateForTraitCollection(
traitCollection,
browserColors: privateBrowsingManager.browserColors
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: true
)

updateColors()
Expand Down Expand Up @@ -106,7 +108,8 @@ class BottomToolbarView: UIView, ToolbarProtocol {
super.traitCollectionDidChange(previousTraitCollection)
helper?.updateForTraitCollection(
traitCollection,
browserColors: privateBrowsingManager.browserColors
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ class ToolbarHelper: NSObject {
func updateForTraitCollection(
_ traitCollection: UITraitCollection,
browserColors: some BrowserColors,
isBottomToolbar: Bool,
additionalButtons: [UIButton] = []
) {
let toolbarTraitCollection = UITraitCollection(
preferredContentSizeCategory: traitCollection.toolbarButtonContentSizeCategory
)
let config = UIImage.SymbolConfiguration(
pointSize: UIFont.preferredFont(forTextStyle: .body, compatibleWith: toolbarTraitCollection)
.pointSize,
pointSize: isBottomToolbar
? UIFont.preferredFont(forTextStyle: .body, compatibleWith: toolbarTraitCollection)
.pointSize
: UIFontMetrics.default.scaledValue(for: 14, compatibleWith: toolbarTraitCollection),
weight: .regular,
scale: .large
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RewardsButton: UIButton {

adjustsImageWhenHighlighted = false
imageView?.contentMode = .scaleAspectFit
contentHorizontalAlignment = .fill
contentVerticalAlignment = .fill
imageView?.adjustsImageSizeForAccessibilityContentSizeCategory = true

accessibilityLabel = Strings.rewardsPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,14 @@ class TopToolbarView: UIView, ToolbarProtocol {
button.accessibilityLabel = Strings.bravePanel
button.imageView?.adjustsImageSizeForAccessibilityContentSizeCategory = true
button.accessibilityIdentifier = "urlBar-shieldsButton"
button.contentEdgeInsets = .init(top: 4, left: 5, bottom: 4, right: 5)
button.contentHorizontalAlignment = .fill
button.contentVerticalAlignment = .fill
return button
}()

private(set) lazy var rewardsButton: RewardsButton = {
let button = RewardsButton()
button.addTarget(self, action: #selector(didTapBraveRewardsButton), for: .touchUpInside)
// Visual centering
button.contentEdgeInsets = .init(top: 4, left: 4, bottom: 6, right: 4)
return button
}()

Expand Down Expand Up @@ -389,14 +388,16 @@ class TopToolbarView: UIView, ToolbarProtocol {
self.updateColors()
self.helper?.updateForTraitCollection(
self.traitCollection,
browserColors: privateBrowsingManager.browserColors
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: false
)
})

updateURLBarButtonsVisibility()
helper?.updateForTraitCollection(
traitCollection,
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: false,
additionalButtons: [shortcutButton]
)
updateForTraitCollection()
Expand Down Expand Up @@ -439,6 +440,7 @@ class TopToolbarView: UIView, ToolbarProtocol {
helper?.updateForTraitCollection(
traitCollection,
browserColors: privateBrowsingManager.browserColors,
isBottomToolbar: false,
additionalButtons: [shortcutButton]
)
updateForTraitCollection()
Expand All @@ -447,7 +449,7 @@ class TopToolbarView: UIView, ToolbarProtocol {
private func updateForTraitCollection() {
let toolbarSizeCategory = traitCollection.toolbarButtonContentSizeCategory
let pointSize = UIFontMetrics(forTextStyle: .body).scaledValue(
for: 28,
for: 24,
compatibleWith: .init(preferredContentSizeCategory: toolbarSizeCategory)
)
shieldsButton.snp.remakeConstraints {
Expand Down Expand Up @@ -751,10 +753,10 @@ class TopToolbarView: UIView, ToolbarProtocol {
if cancelButton.isHidden == inOverlayMode {
cancelButton.isHidden = !inOverlayMode
}
backButton.isHidden = !toolbarIsShowing || inOverlayMode
forwardButton.isHidden = !toolbarIsShowing || inOverlayMode
shareButton.isHidden = !toolbarIsShowing || inOverlayMode
trailingItemsStackView.isHidden = !toolbarIsShowing || inOverlayMode
backButton.isHidden = toolbarIsShowing || inOverlayMode
forwardButton.isHidden = toolbarIsShowing || inOverlayMode
shareButton.isHidden = toolbarIsShowing || inOverlayMode
trailingItemsStackView.isHidden = toolbarIsShowing || inOverlayMode
locationView.contentView.isHidden = inOverlayMode
shieldsRewardsStack.isHidden = inOverlayMode

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "brave.basicattentiontoken.greyscale.pdf",
"filename" : "brave.basicattentiontoken.greyscale.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "brave.basicattentiontoken.pdf",
"filename" : "brave.basicattentiontoken.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "brave.logo.greyscale.pdf",
"filename" : "brave.logo.greyscale.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "brave.logo.pdf",
"filename" : "brave.logo.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d07147e

Please sign in to comment.