From d749533512031a2a92a47073b42dc3f16a5d0b20 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 brave/brave-ios#8206, fix brave/brave-ios#8207: Back-Forward list UI improvements (brave/brave-ios#8208) This commit also updates NTP/internal url to use Brave's logo, ref brave/brave-ios#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 99ffb39fd528..b035b210df9e 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 1a3b6f4d5bb7..51e020c1d426 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 + } }