Skip to content

Commit

Permalink
Fix brave/brave-ios#8206, fix brave/brave-ios#8207: Back-Forward list…
Browse files Browse the repository at this point in the history
… UI improvements (brave/brave-ios#8208)

This commit also updates NTP/internal url to use Brave's logo, ref brave/brave-ios#5357
  • Loading branch information
iccub authored Oct 13, 2023
1 parent 251d70f commit d749533
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 d749533

Please sign in to comment.