diff --git a/Time Progress.xcodeproj/project.pbxproj b/Time Progress.xcodeproj/project.pbxproj index c6c6db0..f077593 100644 --- a/Time Progress.xcodeproj/project.pbxproj +++ b/Time Progress.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 38EFF300D3A93D86029E27A1 /* Pods_Time_Progress.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0350F8373A666A8FFF9E65B2 /* Pods_Time_Progress.framework */; }; 4A21BFFB21A3D38000BDC4F9 /* NSButtonLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A21BFFA21A3D38000BDC4F9 /* NSButtonLabel.swift */; }; 4A6E5A1521A4EEF9000FFA44 /* DateExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E5A1421A4EEF9000FFA44 /* DateExtensions.swift */; }; - 4AE37AE621ADFB0400FFF909 /* CustomDeadline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE37AE521ADFB0400FFF909 /* CustomDeadline.swift */; }; + 4AE37AE621ADFB0400FFF909 /* Deadline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AE37AE521ADFB0400FFF909 /* Deadline.swift */; }; 4AF1127321A2B515005619FB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AF1127221A2B515005619FB /* AppDelegate.swift */; }; 4AF1127521A2B515005619FB /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AF1127421A2B515005619FB /* Preferences.swift */; }; 4AF1127721A2B516005619FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4AF1127621A2B516005619FB /* Assets.xcassets */; }; @@ -27,7 +27,7 @@ 4A8B4B6B21A64E21001DDC41 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LaunchAtLogin.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4A8B4B6D21A64EAF001DDC41 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LaunchAtLogin.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4ACCB55D21A6500E002F3D90 /* LaunchAtLogin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = LaunchAtLogin.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 4AE37AE521ADFB0400FFF909 /* CustomDeadline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDeadline.swift; sourceTree = ""; }; + 4AE37AE521ADFB0400FFF909 /* Deadline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Deadline.swift; sourceTree = ""; }; 4AF1126F21A2B515005619FB /* Time Progress.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Time Progress.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4AF1127221A2B515005619FB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4AF1127421A2B515005619FB /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; @@ -79,7 +79,7 @@ 4A6E5A1421A4EEF9000FFA44 /* DateExtensions.swift */, 4AF1127621A2B516005619FB /* Assets.xcassets */, 4AF1127821A2B517005619FB /* Main.storyboard */, - 4AE37AE521ADFB0400FFF909 /* CustomDeadline.swift */, + 4AE37AE521ADFB0400FFF909 /* Deadline.swift */, 4AF1127B21A2B517005619FB /* Info.plist */, 4A21BFFA21A3D38000BDC4F9 /* NSButtonLabel.swift */, ); @@ -230,7 +230,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4AE37AE621ADFB0400FFF909 /* CustomDeadline.swift in Sources */, + 4AE37AE621ADFB0400FFF909 /* Deadline.swift in Sources */, 4AF1127521A2B515005619FB /* Preferences.swift in Sources */, 4A6E5A1521A4EEF9000FFA44 /* DateExtensions.swift in Sources */, 4A21BFFB21A3D38000BDC4F9 /* NSButtonLabel.swift in Sources */, diff --git a/Time Progress.xcodeproj/project.xcworkspace/xcuserdata/brianvalente.xcuserdatad/UserInterfaceState.xcuserstate b/Time Progress.xcodeproj/project.xcworkspace/xcuserdata/brianvalente.xcuserdatad/UserInterfaceState.xcuserstate index fd40233..22ba5c6 100644 Binary files a/Time Progress.xcodeproj/project.xcworkspace/xcuserdata/brianvalente.xcuserdatad/UserInterfaceState.xcuserstate and b/Time Progress.xcodeproj/project.xcworkspace/xcuserdata/brianvalente.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Time Progress/AppDelegate.swift b/Time Progress/AppDelegate.swift index ca93ca2..ad4615f 100644 --- a/Time Progress/AppDelegate.swift +++ b/Time Progress/AppDelegate.swift @@ -69,44 +69,56 @@ class AppDelegate: NSObject, NSApplicationDelegate { case "year": return "Year" case "custom": - return CustomDeadline.name + return Deadline.name default: return "" } } func getCurrentModeStringValue() -> String { - switch getCurrentMode() { - case "day": - return String(getDayProgressPercentage()) + "%" - case "week": - return String(getWeekProgressPercentage()) + "%" - case "month": - return String(getMonthProgressPercentage()) + "%" - case "year": - return String(getYearProgressPercentage()) + "%" - case "custom": - return CustomDeadline.stringValue - default: - return "-1%" - } +// switch getCurrentMode() { +// case "day": +// return String(getDayProgressPercentage()) + "%" +// case "week": +// return String(getWeekProgressPercentage()) + "%" +// case "month": +// return String(getMonthProgressPercentage()) + "%" +// case "year": +// return String(getYearProgressPercentage()) + "%" +// case "custom": +// return Deadline.stringValue +// default: +// return "-1%" +// } + + return String(getCurrentModeValue()) + "%" } func getCurrentModeValue() -> Int { + var value = 69 switch getCurrentMode() { case "day": - return getDayProgressPercentage() + value = getDayProgressPercentage() case "week": - return getWeekProgressPercentage() + value = getWeekProgressPercentage() case "month": - return getMonthProgressPercentage() + value = getMonthProgressPercentage() case "year": - return getYearProgressPercentage() - case "custom": - return CustomDeadline.percentage + value = getYearProgressPercentage() + case "custom", + "deadline": + value = Deadline.percentage default: - return 69 + value = 69 + } + + let invert = UserDefaults.standard.bool(forKey: "settings.inversepercentage"); + + if (invert) { + value = 100 - value } + + return value } func getCurrentMode() -> String { @@ -143,7 +155,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func getProgressBarVisibility() -> Bool { - return (UserDefaults.standard.object(forKey: "progressbar.visible") as? Bool) ?? true + //return (UserDefaults.standard.object(forKey: "progressbar.visible") as? Bool) ?? true + return progressBar != nil } func setProgressBarVisibility(bool: Bool) { @@ -152,7 +165,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func loadProgressBarVisibility() { - if getProgressBarVisibility() && progressBar == nil { + if UserDefaults.standard.bool(forKey: "progressbar.visible") && progressBar == nil { progressBar = ProgressBar(frame: NSRect(x: 0, y: 0, width: statusBarButton.frame.height * 1.5, height: statusBarButton.frame.height * 0.6)) progressBar!.progress = CGFloat(getYearProgressPercentage()) / 100 @@ -184,7 +197,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { weekMenuItem = NSMenuItem(title: "Week", action: #selector(setMode), keyEquivalent: ""); monthMenuItem = NSMenuItem(title: "Month", action: #selector(setMode), keyEquivalent: ""); yearMenuItem = NSMenuItem(title: "Year", action: #selector(setMode), keyEquivalent: ""); - customMenuItem = NSMenuItem(title: CustomDeadline.name, action: #selector(setMode), keyEquivalent: ""); + customMenuItem = NSMenuItem(title: Deadline.name, action: #selector(setMode), keyEquivalent: ""); dayMenuItem.identifier = NSUserInterfaceItemIdentifier("day") weekMenuItem.identifier = NSUserInterfaceItemIdentifier("week") @@ -297,7 +310,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { func getWeekProgressPercentage() -> Int { let date = Date() - let thisWeek = date.previous(.monday).midnight.timeIntervalSince1970 + var thisWeek = date.previous(.monday).midnight.timeIntervalSince1970 + + // if today's monday + if (Calendar(identifier: .gregorian).dateComponents([.weekday], from: date).weekday == 2) { + thisWeek = date.midnight.timeIntervalSince1970 + } + let nextWeek = date.next(.monday).midnight.timeIntervalSince1970 let now = date.timeIntervalSince1970 diff --git a/Time Progress/Base.lproj/Main.storyboard b/Time Progress/Base.lproj/Main.storyboard index 795b5bd..8493755 100644 --- a/Time Progress/Base.lproj/Main.storyboard +++ b/Time Progress/Base.lproj/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -619,7 +619,7 @@ - + @@ -706,15 +706,14 @@ - + - - - + + - + @@ -722,7 +721,7 @@ - + - - + + @@ -863,7 +862,7 @@ - + @@ -871,7 +870,7 @@ - + @@ -884,8 +883,8 @@ - - + + @@ -895,30 +894,36 @@ - - - - + + - - + + @@ -1005,24 +1010,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + +