Fixing Reduce Transparency #156

This commit is contained in:
Alex Mazanov 2021-02-06 15:56:43 -05:00
parent 81291933e9
commit efe39394a5
2 changed files with 9 additions and 16 deletions

View File

@ -171,6 +171,10 @@ class App: NSObject {
UserDefaults.standard.string(forKey: "AppleInterfaceStyle") != nil
}
public static var isReduceTransparencyEnabled: Bool {
UserDefaults(suiteName: "com.apple.universalaccess.plist")?.bool(forKey: "reduceTransparency") ?? false
}
public static func checkForUpdates() {
delegate.softwareUpdater.checkForUpdates()
}

View File

@ -127,7 +127,9 @@ extension MenubarItem: NSMenuDelegate {
var params = MenuLineParameters(line: currentTitleLine)
params.params["color"] = "white"
barItem.button?.attributedTitle = atributedTitle(with: params).title
if !App.isReduceTransparencyEnabled {
barItem.button?.attributedTitle = atributedTitle(with: params).title
}
guard let lastUpdated = plugin?.lastUpdated else { return }
let formatter = RelativeDateTimeFormatter()
@ -472,30 +474,17 @@ extension MenubarItem {
if let length = params.length, length < title.count {
title = String(title.prefix(length)).appending("...")
}
let isMultilineTitle = title.contains("\\n")
title = title.replacingOccurrences(of: "\\n", with: "\n")
let fontSize = params.size ?? 0
let color = params.color ?? NSColor.labelColor
let font = NSFont(name: params.font ?? "", size: fontSize) ??
NSFont.menuBarFont(ofSize: fontSize)
let offset = font.menuBarOffset
let style = NSMutableParagraphStyle()
style.alignment = .left
var offset: CGFloat = 0
// custom offset for Big Sur, Catalina doesn't need one
if #available(OSX 11.0, *) {
offset = font.menuBarOffset
if isMultilineTitle {
offset = -5
}
}
if isMultilineTitle {
style.paragraphSpacing = 0.1
}
var attributedTitle = NSMutableAttributedString(string: title)
if params.symbolize, !params.ansi {