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

Commit

Permalink
Fix #8207: Make selected url in back-forward list more visible.
Browse files Browse the repository at this point in the history
This commit also updates NTP/internal url to use Brave's logo, ref #5357
  • Loading branch information
iccub committed Oct 9, 2023
1 parent a87114e commit 224af6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BackForwardTableViewCell: UITableViewCell {
}

lazy var faviconView: UIImageView = {
let faviconView = UIImageView(image: Favicon.defaultImage)
let faviconView = UIImageView(image: UIImage(sharedNamed: "brave.logo"))
faviconView.backgroundColor = .braveBackground
faviconView.layer.cornerRadius = 6
faviconView.layer.cornerCurve = .continuous
Expand Down Expand Up @@ -61,6 +61,7 @@ class BackForwardTableViewCell: UITableViewCell {
didSet {
if isCurrentTab {
label.font = UIFont(name: "HelveticaNeue-Bold", size: BackForwardViewCellUX.fontSize)
contentView.backgroundColor = .secondaryBraveBackground
}
}
}
Expand All @@ -70,7 +71,7 @@ class BackForwardTableViewCell: UITableViewCell {
if let s = site {
if InternalURL.isValid(url: s.tileURL) {
faviconView.backgroundColor = .white
faviconView.image = Favicon.defaultImage
faviconView.image = UIImage(sharedNamed: "brave.logo")?.imageWithInsets(insets: .init(equalInset: 4))
} else {
faviconView.loadFavicon(for: s.tileURL, isPrivateBrowsing: isPrivateBrowsing)
}
Expand Down
12 changes: 12 additions & 0 deletions Sources/Shared/Extensions/UIImageExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@ extension UIImage {
UIGraphicsEndImageContext()
return newImage
}

public func imageWithInsets(insets: UIEdgeInsets) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(
CGSize(width: self.size.width + insets.left + insets.right,
height: self.size.height + insets.top + insets.bottom), false, self.scale)
let _ = UIGraphicsGetCurrentContext()
let origin = CGPoint(x: insets.left, y: insets.top)
self.draw(at: origin)
let imageWithInsets = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return imageWithInsets
}
}

0 comments on commit 224af6e

Please sign in to comment.