From 8dca22dbd72bb4967423d2f8662012313207dd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Buczek?= Date: Fri, 13 Oct 2023 17:01:55 +0200 Subject: [PATCH] Fix #8206, fix #8207: Back-Forward list UI improvements (#8208) This commit also updates NTP/internal url to use Brave's logo, ref #5357 --- .../Frontend/Browser/BackForwardTableViewCell.swift | 7 ++++--- Sources/Shared/Extensions/UIImageExtensions.swift | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift b/Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift index 99ffb39fd52..b035b210df9 100644 --- a/Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift +++ b/Sources/Brave/Frontend/Browser/BackForwardTableViewCell.swift @@ -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 }() @@ -61,6 +61,7 @@ class BackForwardTableViewCell: UITableViewCell { didSet { if isCurrentTab { label.font = UIFont(name: "HelveticaNeue-Bold", size: BackForwardViewCellUX.fontSize) + contentView.backgroundColor = .secondaryBraveBackground } } } @@ -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) } diff --git a/Sources/Shared/Extensions/UIImageExtensions.swift b/Sources/Shared/Extensions/UIImageExtensions.swift index 1a3b6f4d5bb..51e020c1d42 100644 --- a/Sources/Shared/Extensions/UIImageExtensions.swift +++ b/Sources/Shared/Extensions/UIImageExtensions.swift @@ -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 + } }