|
@@ -4,13 +4,13 @@
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
import Cocoa
|
|
|
-import QuartzCore
|
|
|
|
|
|
|
|
|
|
final class DashboardView: NSView {
|
|
final class DashboardView: NSView {
|
|
|
private enum Theme {
|
|
private enum Theme {
|
|
|
static let pageBackground = NSColor(calibratedWhite: 0.02, alpha: 1)
|
|
static let pageBackground = NSColor(calibratedWhite: 0.02, alpha: 1)
|
|
|
static let chromeBackground = NSColor(calibratedWhite: 0.04, alpha: 1)
|
|
static let chromeBackground = NSColor(calibratedWhite: 0.04, alpha: 1)
|
|
|
static let sidebarBackground = NSColor(calibratedWhite: 0.07, alpha: 1)
|
|
static let sidebarBackground = NSColor(calibratedWhite: 0.07, alpha: 1)
|
|
|
|
|
+ static let mainHostBackground = NSColor(calibratedWhite: 0.06, alpha: 1)
|
|
|
static let selectionFill = NSColor(calibratedWhite: 1, alpha: 0.1)
|
|
static let selectionFill = NSColor(calibratedWhite: 1, alpha: 0.1)
|
|
|
static let cardBackground = NSColor(calibratedWhite: 0.11, alpha: 1)
|
|
static let cardBackground = NSColor(calibratedWhite: 0.11, alpha: 1)
|
|
|
static let toggleBackground = NSColor(calibratedWhite: 0.16, alpha: 1)
|
|
static let toggleBackground = NSColor(calibratedWhite: 0.16, alpha: 1)
|
|
@@ -25,7 +25,6 @@ final class DashboardView: NSView {
|
|
|
private let chromeContainer = NSView()
|
|
private let chromeContainer = NSView()
|
|
|
private let sidebar = NSStackView()
|
|
private let sidebar = NSStackView()
|
|
|
private let mainHost = NSView()
|
|
private let mainHost = NSView()
|
|
|
- private let mainGradient = NeutralGradientBackgroundView()
|
|
|
|
|
private let mainOverlay = NSStackView()
|
|
private let mainOverlay = NSStackView()
|
|
|
private let greetingLabel = NSTextField(labelWithString: "")
|
|
private let greetingLabel = NSTextField(labelWithString: "")
|
|
|
private let subtitleLabel = NSTextField(labelWithString: "")
|
|
private let subtitleLabel = NSTextField(labelWithString: "")
|
|
@@ -101,13 +100,11 @@ final class DashboardView: NSView {
|
|
|
sidebar.translatesAutoresizingMaskIntoConstraints = false
|
|
sidebar.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
|
|
mainHost.translatesAutoresizingMaskIntoConstraints = false
|
|
mainHost.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
+ mainHost.wantsLayer = true
|
|
|
|
|
+ mainHost.layer?.backgroundColor = Theme.mainHostBackground.cgColor
|
|
|
|
|
+ mainHost.layer?.cornerRadius = 16
|
|
|
|
|
+ mainHost.layer?.masksToBounds = true
|
|
|
|
|
|
|
|
- mainGradient.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
- mainGradient.wantsLayer = true
|
|
|
|
|
- mainGradient.layer?.cornerRadius = 16
|
|
|
|
|
- mainGradient.layer?.masksToBounds = true
|
|
|
|
|
-
|
|
|
|
|
- mainHost.addSubview(mainGradient)
|
|
|
|
|
mainHost.addSubview(mainOverlay)
|
|
mainHost.addSubview(mainOverlay)
|
|
|
|
|
|
|
|
mainOverlay.orientation = .vertical
|
|
mainOverlay.orientation = .vertical
|
|
@@ -180,11 +177,6 @@ final class DashboardView: NSView {
|
|
|
sidebar.widthAnchor.constraint(equalToConstant: 225),
|
|
sidebar.widthAnchor.constraint(equalToConstant: 225),
|
|
|
mainHost.widthAnchor.constraint(greaterThanOrEqualToConstant: 720),
|
|
mainHost.widthAnchor.constraint(greaterThanOrEqualToConstant: 720),
|
|
|
|
|
|
|
|
- mainGradient.leadingAnchor.constraint(equalTo: mainHost.leadingAnchor),
|
|
|
|
|
- mainGradient.trailingAnchor.constraint(equalTo: mainHost.trailingAnchor),
|
|
|
|
|
- mainGradient.topAnchor.constraint(equalTo: mainHost.topAnchor),
|
|
|
|
|
- mainGradient.bottomAnchor.constraint(equalTo: mainHost.bottomAnchor),
|
|
|
|
|
-
|
|
|
|
|
mainOverlay.leadingAnchor.constraint(equalTo: mainHost.leadingAnchor),
|
|
mainOverlay.leadingAnchor.constraint(equalTo: mainHost.leadingAnchor),
|
|
|
mainOverlay.trailingAnchor.constraint(equalTo: mainHost.trailingAnchor),
|
|
mainOverlay.trailingAnchor.constraint(equalTo: mainHost.trailingAnchor),
|
|
|
mainOverlay.topAnchor.constraint(equalTo: mainHost.topAnchor),
|
|
mainOverlay.topAnchor.constraint(equalTo: mainHost.topAnchor),
|
|
@@ -345,37 +337,3 @@ final class DashboardView: NSView {
|
|
|
documentContainer.frame = NSRect(x: 0, y: 0, width: bounds.width, height: fittingHeight)
|
|
documentContainer.frame = NSRect(x: 0, y: 0, width: bounds.width, height: fittingHeight)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// MARK: - Neutral main-area gradient (black / grey only)
|
|
|
|
|
-
|
|
|
|
|
-private final class NeutralGradientBackgroundView: NSView {
|
|
|
|
|
- private let gradientLayer = CAGradientLayer()
|
|
|
|
|
-
|
|
|
|
|
- override init(frame frameRect: NSRect) {
|
|
|
|
|
- super.init(frame: frameRect)
|
|
|
|
|
- commonInit()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- required init?(coder: NSCoder) {
|
|
|
|
|
- super.init(coder: coder)
|
|
|
|
|
- commonInit()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private func commonInit() {
|
|
|
|
|
- wantsLayer = true
|
|
|
|
|
- gradientLayer.colors = [
|
|
|
|
|
- NSColor(calibratedWhite: 0.12, alpha: 1).cgColor,
|
|
|
|
|
- NSColor(calibratedWhite: 0.05, alpha: 1).cgColor,
|
|
|
|
|
- NSColor.black.cgColor
|
|
|
|
|
- ]
|
|
|
|
|
- gradientLayer.locations = [0, 0.42, 1] as [NSNumber]
|
|
|
|
|
- gradientLayer.startPoint = CGPoint(x: 0.5, y: 1)
|
|
|
|
|
- gradientLayer.endPoint = CGPoint(x: 0.5, y: 0)
|
|
|
|
|
- layer?.addSublayer(gradientLayer)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- override func layout() {
|
|
|
|
|
- super.layout()
|
|
|
|
|
- gradientLayer.frame = bounds
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|