Skip to content

Commit

Permalink
Gray color as default
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianValente committed Nov 20, 2018
1 parent b0bc83f commit 5765b22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
16 changes: 9 additions & 7 deletions Year Progress/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

progressBar.progress = CGFloat(getYearProgressPercentage()) / 100
progressBar.background = NSColor.gray.withAlphaComponent(0.35)

if let color = UserDefaults.standard.string(forKey: "progressbar_color") {
print(color)
progressBar.foreground = getColorByName(color: color)!
} else {
progressBar.foreground = NSColor.gray
}
progressBar.foreground = getColorByName(color: getProgressBarColorName())!

progressBar.borderColor = NSColor.clear
progressBar.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -94,6 +88,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func getProgressBarColorName() -> String {
if let color = UserDefaults.standard.string(forKey: "progressbar_color") {
return color
} else {
return "gray"
}
}

func getColorByName(color: String) -> NSColor? {
switch (color) {
case "red":
Expand Down
44 changes: 21 additions & 23 deletions Year Progress/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,27 @@ class Preferences: NSViewController {

githubButton.addGestureRecognizer(githubGesture)

if let color = UserDefaults.standard.string(forKey: "progressbar_color") {
switch color {
case "red":
red.state = NSControl.StateValue.on
case "green":
green.state = NSControl.StateValue.on
case "blue":
blue.state = NSControl.StateValue.on
case "yellow":
yellow.state = NSControl.StateValue.on
case "orange":
orange.state = NSControl.StateValue.on
case "purple":
purple.state = NSControl.StateValue.on
case "white":
white.state = NSControl.StateValue.on
case "gray":
gray.state = NSControl.StateValue.on
case "black":
black.state = NSControl.StateValue.on
default:
break
}
switch AppDelegate.shared?.getProgressBarColorName() {
case "red":
red.state = NSControl.StateValue.on
case "green":
green.state = NSControl.StateValue.on
case "blue":
blue.state = NSControl.StateValue.on
case "yellow":
yellow.state = NSControl.StateValue.on
case "orange":
orange.state = NSControl.StateValue.on
case "purple":
purple.state = NSControl.StateValue.on
case "white":
white.state = NSControl.StateValue.on
case "gray":
gray.state = NSControl.StateValue.on
case "black":
black.state = NSControl.StateValue.on
default:
break
}
}

Expand Down

0 comments on commit 5765b22

Please sign in to comment.