From 679e59c20beb8afa0bf7509d857cda7f405472f5 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Tue, 22 Sep 2020 14:33:00 -0700 Subject: [PATCH] Some appearance tweaks --- App/Browser View/BrowserView.swift | 2 +- App/Browser View/BrowserViewController.swift | 2 +- App/Common UI/ReliefButton.swift | 10 ++++---- App/Titlebar and URL Bar/ToolbarView.swift | 11 ++++++--- App/Titlebar and URL Bar/URLBar.swift | 25 ++++++++------------ 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/App/Browser View/BrowserView.swift b/App/Browser View/BrowserView.swift index 4978e52..d18e0c0 100644 --- a/App/Browser View/BrowserView.swift +++ b/App/Browser View/BrowserView.swift @@ -110,7 +110,7 @@ class BrowserView: UIView // Fix web view content insets if let webView = webView { - webView.scrollView.layer.masksToBounds = false // allow content to draw under titlebar/toolbar + webView.scrollView.layer.masksToBounds = true webView.frame = bounds.inset(by: webViewContentInset) } diff --git a/App/Browser View/BrowserViewController.swift b/App/Browser View/BrowserViewController.swift index 5912ead..5f937f1 100644 --- a/App/Browser View/BrowserViewController.swift +++ b/App/Browser View/BrowserViewController.swift @@ -369,7 +369,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat previewProvider: nil) { (menuElements: [UIMenuElement]) -> UIMenu? in let openInNewTab = UIAction(title: "Open in New Tab", - image: UIImage(systemName: "plus.app"), + image: UIImage(systemName: "plus.app"), identifier: nil, discoverabilityTitle: nil, attributes: [], diff --git a/App/Common UI/ReliefButton.swift b/App/Common UI/ReliefButton.swift index 972d595..f659f17 100644 --- a/App/Common UI/ReliefButton.swift +++ b/App/Common UI/ReliefButton.swift @@ -13,7 +13,7 @@ class ReliefButton: UIButton internal let backgroundView = GradientView(direction: .vertical, colors: ReliefButton.gradientColors(inverted: false, darkMode: false)) static let padding = CGFloat(24.0) - static let cornerRadius = CGFloat(4.0) + static let cornerRadius = CGFloat(6.0) static let borderWidth = CGFloat(1.0) override var isHighlighted: Bool { @@ -55,12 +55,14 @@ class ReliefButton: UIButton shadowView.layer.masksToBounds = false shadowView.layer.shouldRasterize = true shadowView.layer.rasterizationScale = UIScreen.main.scale + shadowView.layer.cornerCurve = .continuous addSubview(shadowView) backgroundView.layer.cornerRadius = Self.cornerRadius backgroundView.isUserInteractionEnabled = false backgroundView.layer.masksToBounds = true backgroundView.layer.borderWidth = Self.borderWidth + backgroundView.layer.cornerCurve = .continuous addSubview(backgroundView) traitCollectionDidChange(nil) @@ -138,13 +140,9 @@ class ReliefButton: UIButton sendSubviewToBack(backgroundView) sendSubviewToBack(shadowView) - let backgroundDimension = bounds.height - 1.0 + let backgroundDimension = bounds.height backgroundView.frame = CGRect(origin: .zero, size: CGSize(width: backgroundDimension, height: backgroundDimension)) backgroundView.frame = backgroundView.frame.centeredX(inRect: bounds) shadowView.frame = backgroundView.frame - - // Offset by a small amount. Visual illusion caused by the shadow - backgroundView.frame = backgroundView.frame.offsetBy(dx: 0.0, dy: 1.0) - shadowView.frame = shadowView.frame.offsetBy(dx: 0.0, dy: 1.0) } } diff --git a/App/Titlebar and URL Bar/ToolbarView.swift b/App/Titlebar and URL Bar/ToolbarView.swift index 1a06a3d..ec62cdc 100644 --- a/App/Titlebar and URL Bar/ToolbarView.swift +++ b/App/Titlebar and URL Bar/ToolbarView.swift @@ -14,7 +14,7 @@ class ToolbarView: UIView var cancelButtonVisible: Bool = false { didSet { layoutSubviews() } } let containerView = UIView(frame: .zero) - let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemThickMaterial)) + let backgroundView = GradientView(direction: .vertical, colors: [.tertiarySystemGroupedBackground, .secondarySystemGroupedBackground]) let cancelButton = UIButton(type: .system) let leadingButtonsView = ToolbarButtonContainerView(frame: .zero) @@ -95,11 +95,16 @@ class ToolbarView: UIView } if let urlBar = urlBar { - let origin = CGPoint( + var origin = CGPoint( x: leadingButtonsView.frame.maxX, y: 0.0 ) + if origin.x == 0 { + // Add some padding if url bar is flush with side + origin.x = layoutMargins.left + } + urlBar.frame = CGRect( origin: origin, size: CGSize( @@ -108,7 +113,7 @@ class ToolbarView: UIView ) ) - urlBar.frame = urlBar.frame.inset(by: urlBarInsets) + urlBar.frame = urlBar.frame.inset(by: urlBarInsets).inset(by: buttonContainerInset) } } } diff --git a/App/Titlebar and URL Bar/URLBar.swift b/App/Titlebar and URL Bar/URLBar.swift index 70f097f..ebc6b28 100644 --- a/App/Titlebar and URL Bar/URLBar.swift +++ b/App/Titlebar and URL Bar/URLBar.swift @@ -7,7 +7,7 @@ import UIKit -class URLBar: UIView +class URLBar: ReliefButton { let textField = UITextField(frame: .zero) let refreshButton = UIButton(frame: .zero) @@ -23,8 +23,6 @@ class URLBar: UIView didSet { updateProgressIndicator() } } - private let backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .systemThickMaterial)) - private let shadowView = UIView(frame: .zero) private let fadeMaskView = UIImageView(frame: .zero) private let progressIndicatorView = ProgressIndicatorView() @@ -33,21 +31,14 @@ class URLBar: UIView private let refreshImage = UIImage(systemName: "arrow.clockwise") private let stopImage = UIImage(systemName: "xmark") - private let backgroundCornerRadius: CGFloat = 4 + private let backgroundCornerRadius: CGFloat = 0 - convenience init() { - self.init(frame: .zero) + override init() { + super.init() backgroundColor = .clear - backgroundView.layer.masksToBounds = true - backgroundView.layer.cornerRadius = backgroundCornerRadius - backgroundView.layer.borderWidth = 1 - backgroundView.layer.borderColor = UIColor.secondarySystemFill.cgColor - backgroundView.isUserInteractionEnabled = false - addSubview(backgroundView) - - backgroundView.contentView.addSubview(progressIndicatorView) + backgroundView.addSubview(progressIndicatorView) textField.backgroundColor = .clear textField.textContentType = .URL @@ -82,6 +73,10 @@ class URLBar: UIView setErrorButtonAnimating(false) } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + private func updateProgressIndicator() { setErrorButtonAnimating(false) @@ -176,7 +171,7 @@ class URLBar: UIView super.layoutSubviews() backgroundView.frame = bounds shadowView.frame = bounds - progressIndicatorView.frame = backgroundView.contentView.bounds + progressIndicatorView.frame = backgroundView.bounds textField.frame = bounds.insetBy(dx: 6.0, dy: 0) var fadeCutoffLocation: CGFloat = 0.8