Dark mode appearance tweaks

This commit is contained in:
James Magahern
2022-02-21 15:52:18 -08:00
parent c8b4242bc6
commit 224a39b64f
3 changed files with 16 additions and 27 deletions

View File

@@ -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
}

View File

@@ -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()

View File

@@ -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