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

Commit

Permalink
Fix #8206, fix #8207: Back-Forward list UI improvements (#8208)
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 13, 2023
1 parent f9d8243 commit 8dca22d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ 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
faviconView.layer.borderWidth = 0.5
faviconView.layer.borderColor = UIColor(white: 0, alpha: 0.1).cgColor
faviconView.layer.masksToBounds = true
faviconView.contentMode = .center
faviconView.contentMode = .scaleAspectFit
return faviconView
}()

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 8dca22d

Please sign in to comment.