From 224a39b64ff8b533572e36221e88496af0e64182 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Mon, 21 Feb 2022 15:52:18 -0800 Subject: [PATCH] Dark mode appearance tweaks --- App/Common UI/ReliefButton.swift | 26 ++++++------------- App/Titlebar and URL Bar/ToolbarView.swift | 15 +++++------ .../ToolbarViewController.swift | 2 +- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/App/Common UI/ReliefButton.swift b/App/Common UI/ReliefButton.swift index a5d680a..651e1ad 100644 --- a/App/Common UI/ReliefButton.swift +++ b/App/Common UI/ReliefButton.swift @@ -80,38 +80,28 @@ class ReliefButton: UIButton } static func gradientColors(inverted: Bool, darkMode: Bool) -> [UIColor] { - if darkMode { - if !inverted { + let colors = { darkMode -> [UIColor] in + if darkMode { return [ - UIColor(white: 0.20, alpha: 1.0), - UIColor(white: 0.10, alpha: 1.0) + UIColor(white: 0.15, alpha: 1.0), + UIColor(white: 0.08, alpha: 1.0) ] } else { - return [ - UIColor(white: 0.10, alpha: 1.0), - UIColor(white: 0.30, alpha: 1.0) - ] - } - } else { - if !inverted { return [ UIColor(white: 0.98, alpha: 1.0), UIColor(white: 0.93, alpha: 1.0) ] - } else { - return [ - UIColor(white: 0.88, alpha: 1.0), - UIColor(white: 0.93, alpha: 1.0) - ] } - } + } (darkMode) + + return inverted ? colors.reversed() : colors } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { setBackgroundInverted(isHighlighted) backgroundView.layer.borderColor = { traitCollection -> UIColor in if traitCollection.userInterfaceStyle == .dark { - return .init(white: 0.34, alpha: 1.0) + return .init(white: 0.30, alpha: 1.0) } else { return .white } diff --git a/App/Titlebar and URL Bar/ToolbarView.swift b/App/Titlebar and URL Bar/ToolbarView.swift index 9e3f8fb..a654844 100644 --- a/App/Titlebar and URL Bar/ToolbarView.swift +++ b/App/Titlebar and URL Bar/ToolbarView.swift @@ -15,13 +15,7 @@ class ToolbarView: UIView let containerView = UIView(frame: .zero) let backgroundView = GradientView(direction: .vertical, colors: [ - .init(dynamicProvider: { traits in - if traits.userInterfaceStyle == .dark { - return UIColor(white: 0.15, alpha: 1.0) - } else { - return UIColor.tertiarySystemGroupedBackground - } - }), + .secondarySystemGroupedBackground, .secondarySystemGroupedBackground ]) let cancelButton = UIButton(type: .system) @@ -50,7 +44,12 @@ class ToolbarView: UIView override func sizeThatFits(_ size: CGSize) -> CGSize { - return CGSize(width: size.width, height: 42.0) + var height: CGFloat = 42.0 + if traitCollection.userInterfaceIdiom == .mac { + height = 40.0 + } + + return CGSize(width: size.width, height: height) } override func layoutSubviews() diff --git a/App/Titlebar and URL Bar/ToolbarViewController.swift b/App/Titlebar and URL Bar/ToolbarViewController.swift index 82867f1..da9b6df 100644 --- a/App/Titlebar and URL Bar/ToolbarViewController.swift +++ b/App/Titlebar and URL Bar/ToolbarViewController.swift @@ -88,7 +88,7 @@ class ToolbarViewController: UIViewController toolbarView.trailingButtonsView.removeAllButtonViews() let spacerView = { () -> SpacerView in - SpacerView(space: 24.0) + SpacerView(space: 20.0) } // Setup toolbar based on trait collection