feat: removed macOS 10.14* checks

This commit is contained in:
Serhiy Mytrovtsiy
2023-02-16 19:44:10 +01:00
parent c7ab1e8a03
commit 03e37cfc4a
13 changed files with 45 additions and 83 deletions

View File

@@ -170,17 +170,17 @@ public class BarChart: WidgetWrapper {
if partitionValue.color == nil {
switch self.colorState {
case .systemAccent: controlAccentColor.set()
case .systemAccent: NSColor.controlAccentColor.set()
case .utilization: partitionValue.value.usageColor(zones: self.colorZones, reversed: self.title == "Battery").set()
case .pressure: self.pressureLevel.pressureColor().set()
case .cluster: (partitionValue.value.clusterColor(i) ?? controlAccentColor).set()
case .cluster: (partitionValue.value.clusterColor(i) ?? .controlAccentColor).set()
case .monochrome:
if self.boxState {
(isDarkMode ? NSColor.black : NSColor.white).set()
} else {
(isDarkMode ? NSColor.white : NSColor.black).set()
}
default: (self.colorState.additional as? NSColor ?? controlAccentColor).set()
default: (self.colorState.additional as? NSColor ?? .controlAccentColor).set()
}
} else {
partitionValue.color?.set()

View File

@@ -134,9 +134,9 @@ public class LineChart: WidgetWrapper {
let offset = lineWidth / 2
var boxSize: CGSize = CGSize(width: self.width - (Constants.Widget.margin.x*2), height: self.frame.size.height)
var color: NSColor = controlAccentColor
var color: NSColor = .controlAccentColor
switch self.colorState {
case .systemAccent: color = controlAccentColor
case .systemAccent: color = .controlAccentColor
case .utilization: color = value.usageColor()
case .pressure: color = self.pressureLevel.pressureColor()
case .monochrome:
@@ -145,7 +145,7 @@ public class LineChart: WidgetWrapper {
} else {
color = (isDarkMode ? NSColor.white : NSColor.black)
}
default: color = self.colorState.additional as? NSColor ?? controlAccentColor
default: color = self.colorState.additional as? NSColor ?? .controlAccentColor
}
if self.labelState {

View File

@@ -119,13 +119,13 @@ public class Mini: WidgetWrapper {
origin.y = 1
}
var color: NSColor = controlAccentColor
var color: NSColor = .controlAccentColor
switch self.colorState {
case .systemAccent: color = controlAccentColor
case .systemAccent: color = .controlAccentColor
case .utilization: color = value.usageColor(zones: self.colorZones, reversed: self.title == "BAT")
case .pressure: color = self.pressureLevel.pressureColor()
case .monochrome: color = (isDarkMode ? NSColor.white : NSColor.black)
default: color = self.colorState.additional as? NSColor ?? controlAccentColor
default: color = self.colorState.additional as? NSColor ?? .controlAccentColor
}
let stringAttributes = [

View File

@@ -121,7 +121,7 @@ public extension DispatchSource.MemoryPressureEvent {
case .critical:
return NSColor.systemRed
default:
return controlAccentColor
return .controlAccentColor
}
}
}
@@ -247,20 +247,11 @@ public extension Double {
public extension NSView {
var isDarkMode: Bool {
if #available(OSX 10.14, *) {
switch effectiveAppearance.name {
case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark:
return true
default:
return false
}
} else {
switch effectiveAppearance.name {
case .vibrantDark:
return true
default:
return false
}
switch effectiveAppearance.name {
case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark:
return true
default:
return false
}
}

View File

@@ -531,7 +531,6 @@ public func isNewestVersion(currentVersion: String, latestVersion: String) -> Bo
return false
}
@available(macOS 10.14, *)
public func showNotification(title: String, subtitle: String? = nil, userInfo: [AnyHashable: Any] = [:], delegate: UNUserNotificationCenterDelegate? = nil) -> String {
let id = UUID().uuidString
@@ -557,7 +556,6 @@ public func showNotification(title: String, subtitle: String? = nil, userInfo: [
return id
}
@available(macOS 10.14, *)
public func removeNotification(_ id: String) {
let center = UNUserNotificationCenter.current()
center.removeDeliveredNotifications(withIdentifiers: [id])
@@ -786,9 +784,7 @@ public class ProcessView: NSStackView {
self.killView.translatesAutoresizingMaskIntoConstraints = false
self.killView.imageScaling = .scaleNone
self.killView.image = Bundle(for: type(of: self)).image(forResource: "cancel")!
if #available(OSX 10.14, *) {
self.killView.contentTintColor = .lightGray
}
self.killView.contentTintColor = .lightGray
self.killView.isBordered = false
self.killView.action = #selector(self.kill)
self.killView.target = self

View File

@@ -290,9 +290,7 @@ internal class HeaderView: NSStackView {
activity.translatesAutoresizingMaskIntoConstraints = false
activity.imageScaling = .scaleNone
activity.image = Bundle(for: type(of: self)).image(forResource: "chart")!
if #available(OSX 10.14, *) {
activity.contentTintColor = .lightGray
}
activity.contentTintColor = .lightGray
activity.isBordered = false
activity.action = #selector(openActivityMonitor)
activity.target = self
@@ -320,9 +318,7 @@ internal class HeaderView: NSStackView {
settings.translatesAutoresizingMaskIntoConstraints = false
settings.imageScaling = .scaleNone
settings.image = Bundle(for: type(of: self)).image(forResource: "settings")!
if #available(OSX 10.14, *) {
settings.contentTintColor = .lightGray
}
settings.contentTintColor = .lightGray
settings.isBordered = false
settings.action = #selector(openSettings)
settings.target = self

View File

@@ -74,7 +74,7 @@ public class LineChartView: NSView {
public var points: [Double]
public var shadowPoints: [Double] = []
public var transparent: Bool = true
public var color: NSColor = controlAccentColor
public var color: NSColor = .controlAccentColor
public var suffix: String = "%"
public var scale: Scale
@@ -699,7 +699,7 @@ public class BarChartView: NSView {
public init(frame: NSRect, num: Int) {
super.init(frame: frame)
self.values = Array(repeating: ColorValue(0, color: controlAccentColor), count: num)
self.values = Array(repeating: ColorValue(0, color: .controlAccentColor), count: num)
}
required init?(coder: NSCoder) {
@@ -724,7 +724,7 @@ public class BarChartView: NSView {
partition.close()
let value = self.values[i]
let color = value.color ?? controlAccentColor
let color = value.color ?? .controlAccentColor
let activeBlockNum = Int(round(value.value*Double(blocks)))
var y: CGFloat = spacing

View File

@@ -138,7 +138,7 @@ extension Color: CaseIterable {
public static var separator1: Color { return Color(key: "separator_1", value: "separator_1", additional: NSColor.black) }
public static var systemAccent: Color { return Color(key: "system", value: "System accent", additional: controlAccentColor) }
public static var systemAccent: Color { return Color(key: "system", value: "System accent", additional: NSColor.controlAccentColor) }
public static var monochrome: Color { return Color(key: "monochrome", value: "Monochrome accent", additional: NSColor.textColor) }
public static var separator2: Color { return Color(key: "separator_2", value: "separator_2", additional: NSColor.black) }
@@ -197,16 +197,6 @@ extension Color: CaseIterable {
}
}
public var controlAccentColor: NSColor {
get {
if #available(OSX 10.14, *) {
return NSColor.controlAccentColor
} else {
return NSColor.systemBlue
}
}
}
public class MonochromeColor {
static public let base: NSColor = NSColor.textColor
static public let red: NSColor = NSColor(red: (145), green: (145), blue: (145), alpha: 1)

View File

@@ -308,7 +308,7 @@ internal class BarView: NSView {
let width: CGFloat = (view.frame.width * (percentage < 0 ? 0 : percentage)) / 1
self.usedBarSpace = NSView(frame: NSRect(x: 0, y: 0, width: width, height: view.frame.height))
self.usedBarSpace?.wantsLayer = true
self.usedBarSpace?.layer?.backgroundColor = controlAccentColor.cgColor
self.usedBarSpace?.layer?.backgroundColor = NSColor.controlAccentColor.cgColor
view.addSubview(self.usedBarSpace!)
self.addSubview(view)

View File

@@ -194,9 +194,7 @@ internal class Popup: NSStackView, Popup_p {
button.bezelStyle = .regularSquare
button.isBordered = false
button.imageScaling = NSImageScaling.scaleAxesIndependently
if #available(OSX 10.14, *) {
button.contentTintColor = .lightGray
}
button.contentTintColor = .lightGray
button.action = #selector(self.resetTotalNetworkUsage)
button.target = self
button.toolTip = localizedString("Reset")
@@ -249,9 +247,7 @@ internal class Popup: NSStackView, Popup_p {
button.bezelStyle = .regularSquare
button.isBordered = false
button.imageScaling = NSImageScaling.scaleAxesIndependently
if #available(OSX 10.14, *) {
button.contentTintColor = .lightGray
}
button.contentTintColor = .lightGray
button.action = #selector(self.refreshPublicIP)
button.target = self
button.toolTip = localizedString("Refresh")

View File

@@ -93,7 +93,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
return true
}
@available(macOS 10.14, *)
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {

View File

@@ -411,9 +411,7 @@ private class SidebarView: NSStackView {
button.translatesAutoresizingMaskIntoConstraints = false
button.imageScaling = .scaleNone
button.image = image
if #available(OSX 10.14, *) {
button.contentTintColor = .secondaryLabelColor
}
button.contentTintColor = .secondaryLabelColor
button.isBordered = false
button.action = action
button.target = self

View File

@@ -167,30 +167,26 @@ extension AppDelegate {
debug("show update view because new version of app found: \(version.latest)")
if #available(OSX 10.14, *) {
let center = UNUserNotificationCenter.current()
center.getNotificationSettings { settings in
switch settings.authorizationStatus {
case .authorized, .provisional:
self.showUpdateNotification(version: version)
case .denied:
self.showUpdateWindow(version: version)
case .notDetermined:
center.requestAuthorization(options: [.sound, .alert, .badge], completionHandler: { (_, error) in
if error == nil {
NSApplication.shared.registerForRemoteNotifications()
self.showUpdateNotification(version: version)
} else {
self.showUpdateWindow(version: version)
}
})
@unknown default:
self.showUpdateWindow(version: version)
error_msg("unknown notification setting")
}
let center = UNUserNotificationCenter.current()
center.getNotificationSettings { settings in
switch settings.authorizationStatus {
case .authorized, .provisional:
self.showUpdateNotification(version: version)
case .denied:
self.showUpdateWindow(version: version)
case .notDetermined:
center.requestAuthorization(options: [.sound, .alert, .badge], completionHandler: { (_, error) in
if error == nil {
NSApplication.shared.registerForRemoteNotifications()
self.showUpdateNotification(version: version)
} else {
self.showUpdateWindow(version: version)
}
})
@unknown default:
self.showUpdateWindow(version: version)
error_msg("unknown notification setting")
}
} else {
self.showUpdateWindow(version: version)
}
}
}