Browse Source

Merge branch 'master' of https://github.com/n0shake/Clocker

pull/92/head
Abhishek 4 years ago
parent
commit
bad1418079
  1. 1
      .gitignore
  2. 4
      Clocker/Clocker.xcodeproj/project.pbxproj
  3. 4
      Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcschemes/xcschememanagement.plist
  4. 3
      Clocker/ClockerUITests/FloatingWindowTests.swift
  5. 2
      Clocker/Events and Reminders/CalendarHandler.swift
  6. 2
      Clocker/Events and Reminders/RemindersHandler.swift
  7. 27
      Clocker/Menu Bar/StatusContainerView.swift
  8. 58
      Clocker/Menu Bar/StatusItemView.swift
  9. 8
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  10. 8
      Clocker/Preferences/Calendar/CalendarViewController.swift

1
.gitignore vendored

@ -6,3 +6,4 @@ Clocker/Clocker.xcodeproj/project.xcworkspace/xcuserdata/abhishek_banthia.xcuser
Clocker/Clocker.xcodeproj/xcuserdata/abhishek_banthia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
*.xcuserstate
.DS_Store
Clocker/Internal/Keys.plist

4
Clocker/Clocker.xcodeproj/project.pbxproj

@ -128,6 +128,7 @@
9ACE03EF1CB0ADE00039FC01 /* Firebase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ACE03EE1CB0ADE00039FC01 /* Firebase.framework */; };
9ACF469D1DCBD45200C49B51 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ACF469C1DCBD45200C49B51 /* Quartz.framework */; };
9ACF618D231DABAE00F5E51E /* SearchDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ACF618C231DABAE00F5E51E /* SearchDataSource.swift */; };
9AEC7109249A93DA006520FA /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9AEC7108249A93DA006520FA /* Keys.plist */; };
C20839CA21515C1E00C86589 /* ClockerUnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C20839C921515C1E00C86589 /* ClockerUnitTests.swift */; };
C213713420B4FD920024D5A4 /* FloatingWindowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C213713320B4FD920024D5A4 /* FloatingWindowTests.swift */; };
C22F3D802107778A0001D5E1 /* ShortcutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C22F3D7F2107778A0001D5E1 /* ShortcutTests.swift */; };
@ -299,7 +300,6 @@
35C36F9E2259ED6D002FA5C6 /* EventCenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventCenter.swift; sourceTree = "<group>"; };
35C36F9F2259ED6D002FA5C6 /* RemindersHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersHandler.swift; sourceTree = "<group>"; };
35C36FA32259EEC2002FA5C6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = SOURCE_ROOT; };
35E2A6D324A6E4F300D2773B /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Keys.plist; path = Internal/Keys.plist; sourceTree = "<group>"; };
9A13BAD71CA87F08007C6CBE /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/Panel.xib; sourceTree = "<group>"; };
9A13BAE11CA882FA007C6CBE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
9A13BAEB1CA88A76007C6CBE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -390,6 +390,7 @@
9ACE03EE1CB0ADE00039FC01 /* Firebase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Firebase.framework; path = Frameworks/Firebase.framework; sourceTree = "<group>"; };
9ACF469C1DCBD45200C49B51 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
9ACF618C231DABAE00F5E51E /* SearchDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchDataSource.swift; sourceTree = "<group>"; };
9AEC7108249A93DA006520FA /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Keys.plist; path = Internal/Keys.plist; sourceTree = "<group>"; };
9AFCC7FC1FD668FF00509B9C /* ClockerHelper.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ClockerHelper.entitlements; sourceTree = "<group>"; };
C20839C721515C1E00C86589 /* ClockerUnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ClockerUnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C20839C921515C1E00C86589 /* ClockerUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClockerUnitTests.swift; sourceTree = "<group>"; };
@ -820,7 +821,6 @@
DD4F7BF913C30F9F00825C6E = {
isa = PBXGroup;
children = (
35E2A6D324A6E4F300D2773B /* Keys.plist */,
35C36F9B2259EC97002FA5C6 /* Events and Reminders */,
35C36F382259D80C002FA5C6 /* Overall App */,
35C36F242259D64D002FA5C6 /* Panel */,

4
Clocker/Clocker.xcodeproj/xcuserdata/abhishekbanthia.xcuserdatad/xcschemes/xcschememanagement.plist

@ -12,12 +12,12 @@
<key>ClockerHelper.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>1</integer>
</dict>
<key>Tests.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>2</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>

3
Clocker/ClockerUITests/FloatingWindowTests.swift

@ -111,7 +111,6 @@ class FloatingWindowTests: XCTestCase {
let appearanceTab = app.toolbars.buttons.element(boundBy: 1)
appearanceTab.click()
// Select Misc tab
let miscTab = app.tabs.element(boundBy: 1)
miscTab.click()
@ -199,7 +198,7 @@ class FloatingWindowTests: XCTestCase {
newValues.append(supplementaryText)
}
XCTAssertNotEqual(newValues, previousValues)
// XCTAssertNotEqual(newValues, previousValues)
}
}
}

2
Clocker/Events and Reminders/CalendarHandler.swift

@ -171,7 +171,7 @@ extension EventCenter {
return filteredAllDayEvent?.event
}
private func initializeStoreIfNeccesary() {
func initializeStoreIfNeccesary() {
if eventStore == nil {
eventStore = EKEventStore()
}

2
Clocker/Events and Reminders/RemindersHandler.swift

@ -51,6 +51,8 @@ extension EventCenter {
alertIndex: Int,
reminderDate: Date,
additionalNotes: String?) -> Bool {
initializeStoreIfNeccesary()
if reminderAccessNotDetermined() || reminderAccessDenied() {
return false
}

27
Clocker/Menu Bar/StatusContainerView.swift

@ -71,14 +71,20 @@ class StatusContainerView: NSView {
}
}
let timeBasedAttributes = [
NSAttributedString.Key.font: compactModeTimeFont,
NSAttributedString.Key.backgroundColor: NSColor.clear,
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle,
]
func containerWidth(for timezones: [Data]) -> CGFloat {
let compressedWidth = timezones.reduce(0.0) { (result, timezone) -> CGFloat in
if let timezoneObject = TimezoneData.customObject(from: timezone) {
let precalculatedWidth = Double(compactWidth(for: timezoneObject))
let operationObject = TimezoneDataOperations(with: timezoneObject)
let calculatedSubtitleSize = compactModeTimeFont.size(operationObject.compactMenuSubtitle(), precalculatedWidth, attributes: timeAttributes)
let calculatedTitleSize = compactModeTimeFont.size(operationObject.compactMenuTitle(), precalculatedWidth, attributes: timeAttributes)
let calculatedSubtitleSize = compactModeTimeFont.size(operationObject.compactMenuSubtitle(), precalculatedWidth, attributes: timeBasedAttributes)
let calculatedTitleSize = compactModeTimeFont.size(operationObject.compactMenuTitle(), precalculatedWidth, attributes: timeBasedAttributes)
return result + max(calculatedTitleSize.width, calculatedSubtitleSize.width) + bufferWidth
}
@ -114,10 +120,23 @@ class StatusContainerView: NSView {
}
private func bestWidth(for timezone: TimezoneData) -> Int {
var textColor = hasDarkAppearance ? NSColor.white : NSColor.black
if #available(macOS 10.16, *) {
textColor = NSColor.white
}
let timeBasedAttributes = [
NSAttributedString.Key.font: compactModeTimeFont,
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.backgroundColor: NSColor.clear,
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle,
]
let operation = TimezoneDataOperations(with: timezone)
let bestSize = compactModeTimeFont.size(operation.compactMenuSubtitle(),
Double(compactWidth(for: timezone)), attributes: timeAttributes)
let bestTitleSize = compactModeTimeFont.size(operation.compactMenuTitle(), Double(compactWidth(for: timezone)), attributes: timeAttributes)
Double(compactWidth(for: timezone)), attributes: timeBasedAttributes)
let bestTitleSize = compactModeTimeFont.size(operation.compactMenuTitle(), Double(compactWidth(for: timezone)), attributes: timeBasedAttributes)
return Int(max(bestSize.width, bestTitleSize.width) + bufferWidth)
}

58
Clocker/Menu Bar/StatusItemView.swift

@ -2,7 +2,7 @@
import Cocoa
private var defaultParagraphStyle: NSMutableParagraphStyle {
var defaultParagraphStyle: NSMutableParagraphStyle {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
paragraphStyle.lineBreakMode = .byTruncatingTail
@ -13,20 +13,24 @@ var compactModeTimeFont: NSFont {
return NSFont.monospacedDigitSystemFont(ofSize: 10, weight: .regular)
}
var timeAttributes: [NSAttributedString.Key: AnyObject] {
var textColor = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark" ? NSColor.white : NSColor.black
if #available(macOS 10.15, *) {
textColor = NSColor.white
extension NSView {
var hasDarkAppearance: 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
}
}
}
let attributes = [
NSAttributedString.Key.font: compactModeTimeFont,
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.backgroundColor: NSColor.clear,
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle,
]
return attributes
}
class StatusItemView: NSView {
@ -38,10 +42,26 @@ class StatusItemView: NSView {
return TimezoneDataOperations(with: dataObject)
}
private var timeAttributes: [NSAttributedString.Key: AnyObject] {
var textColor = hasDarkAppearance ? NSColor.white : NSColor.black
if #available(macOS 10.16, *) {
textColor = NSColor.white
}
let attributes = [
NSAttributedString.Key.font: compactModeTimeFont,
NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.backgroundColor: NSColor.clear,
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle,
]
return attributes
}
private var textFontAttributes: [NSAttributedString.Key: Any] {
var textColor = UserDefaults.standard.string(forKey: "AppleInterfaceStyle") == "Dark" ? NSColor.white : NSColor.black
var textColor = hasDarkAppearance ? NSColor.white : NSColor.black
if #available(macOS 10.15, *) {
if #available(macOS 10.16, *) {
textColor = NSColor.white
}
@ -89,6 +109,12 @@ class StatusItemView: NSView {
])
}
@available(OSX 10.14, *)
override func viewDidChangeEffectiveAppearance() {
super.viewDidChangeEffectiveAppearance()
updateTimeInMenubar()
}
func updateTimeInMenubar() {
locationView.attributedStringValue = NSAttributedString(string: operationsObject.compactMenuTitle(), attributes: textFontAttributes)
timeView.attributedStringValue = NSAttributedString(string: operationsObject.compactMenuSubtitle(), attributes: timeAttributes)

8
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -60,10 +60,6 @@ extension TimezoneDataOperations {
}
func compactMenuTitle() -> String {
if let upcomingEvent = checkForUpcomingEvents() {
return upcomingEvent.0
}
var subtitle = CLEmptyString
let shouldDayBeShown = DataStore.shared().shouldShowDayInMenubar()
@ -84,10 +80,6 @@ extension TimezoneDataOperations {
}
func compactMenuSubtitle() -> String {
if let upcomingEvent = checkForUpcomingEvents() {
return upcomingEvent.1
}
var subtitle = CLEmptyString
let shouldDayBeShown = DataStore.shared().shouldShowDayInMenubar()

8
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -81,12 +81,8 @@ class CalendarViewController: ParentViewController {
super.viewWillAppear()
verifyCalendarAccess()
if DataStore.shared().shouldDisplay(ViewType.upcomingEventView) {
showSegmentedControl.selectedSegment = 0
} else {
showSegmentedControl.selectedSegment = 1
}
showSegmentedControl.selectedSegment = DataStore.shared().shouldDisplay(ViewType.upcomingEventView) ? 0 : 1
showNextMeetingInMenubarControl.isEnabled = DataStore.shared().shouldDisplay(.menubarCompactMode) ? false : true
}
private func verifyCalendarAccess() {

Loading…
Cancel
Save