Skip to content

Commit

Permalink
theme is now detected in each update interval
Browse files Browse the repository at this point in the history
fixes #72
  • Loading branch information
D0miH committed Jan 25, 2020
1 parent 328d646 commit 2fc9762
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
9 changes: 2 additions & 7 deletions iGlance/iGlance/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@
import Cocoa
import ServiceManagement

enum InterfaceStyle: String {
case Dark, Light

init() {
let type = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") ?? "Light"
self = InterfaceStyle(rawValue: type)!
}
func isDarkMode() -> Bool {
return UserDefaults.standard.string(forKey: "AppleInterfaceStyle") != nil ? true : false
}

extension NSColor {
Expand Down
2 changes: 1 addition & 1 deletion iGlance/iGlance/Components/BatteryComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class BatteryComponent {
// determine the color scheme and set the font color accordingly
var batteryIconString: String?
var fontColor: NSColor?
if InterfaceStyle() == InterfaceStyle.Dark {
if isDarkMode() {
batteryIconString = "battery-icon-white"
fontColor = NSColor.white
} else {
Expand Down
2 changes: 1 addition & 1 deletion iGlance/iGlance/Components/CpuUsageComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CpuUsageComponent {
myCpuMenuView.percentUser.stringValue = String(Int(cpuUser)) + "%"
myCpuMenuView.percentIdle.stringValue = String(Int(cpuIdle)) + "%"

if InterfaceStyle() == InterfaceStyle.Dark {
if isDarkMode() {
cpuImg = "menubar-label-cpu-white"
pbImg = "progressbar-white"
} else {
Expand Down
2 changes: 1 addition & 1 deletion iGlance/iGlance/Components/MemUsageComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class MemUsageComponent {
let memTaken = memActive + memCompressed + memWired
let totalMemUsage = Double(memTaken / System.physicalMemory()) * 100

if InterfaceStyle() == InterfaceStyle.Dark {
if isDarkMode() {
memImg = "menubar-label-mem-white"
pbIMG = "progressbar-white"
} else {
Expand Down
2 changes: 1 addition & 1 deletion iGlance/iGlance/Components/NetUsageComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class NetUsageComponent {
updateMenuText(down: getTotalDownloaded(), up: getTotalUploaded())
}

if InterfaceStyle() == InterfaceStyle.Dark {
if isDarkMode() {
bandIMG = "bandwidth-white"
bandColor = NSColor.white
} else {
Expand Down
2 changes: 1 addition & 1 deletion iGlance/iGlance/Utils/MenuBarGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MenuBarGraph {
if drawBorder {
// draw the border around the graph area
let borderRect = NSRect(x: 6, y: 0, width: width-8, height: 18)
if InterfaceStyle() == InterfaceStyle.Dark {
if isDarkMode() {
NSColor.white.set()
} else {
NSColor.black.set()
Expand Down

0 comments on commit 2fc9762

Please sign in to comment.