Browse Source

Swiftformat.

pull/113/head
Abhishek 2 years ago
parent
commit
16163387e7
  1. 9
      Clocker/ClockerUnitTests/ThemerTests.swift
  2. 8
      Clocker/Panel/UI/TimezoneCellView.swift
  3. 15
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  4. 4
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

9
Clocker/ClockerUnitTests/ThemerTests.swift

@ -229,9 +229,9 @@ class ThemerTests: XCTestCase {
private func testSubject(subject: Themer, withExpectatations expectations: ThemeExpectations) {
// Symbol images were introduced in 11.0; Clocker still supports 10.13+ so few asserts below that rely on symbol images will fail.
let eligibleOSVersion = ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 11, minorVersion: 0, patchVersion: 0))
if (eligibleOSVersion) {
let eligibleOSVersion = ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 11, minorVersion: 0, patchVersion: 0))
if eligibleOSVersion {
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectations.expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectations.expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectations.expectedPinImageName)
@ -252,7 +252,7 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.sharingImage().accessibilityDescription, expectations.expectedSharingImage)
XCTAssertEqual(subject.currentLocationImage().accessibilityDescription, expectations.expectedCurrentLocationImage)
}
XCTAssertEqual(subject.sliderKnobColor(), expectations.expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectations.expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectations.expectedBackgroundColor)
@ -262,6 +262,5 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectations.expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectations.expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.popoverAppearance(), expectations.expectedPopoverApperarance)
}
}

8
Clocker/Panel/UI/TimezoneCellView.swift

@ -12,9 +12,9 @@ class TimezoneCellView: NSTableCellView {
@IBOutlet var extraOptions: NSButton!
@IBOutlet var sunriseImage: NSImageView!
@IBOutlet var currentLocationIndicator: NSImageView!
static private let minimumFontSizeForTime: Int = 11
static private let minimumFontSizeForLabel: Int = 10
private static let minimumFontSizeForTime: Int = 11
private static let minimumFontSizeForLabel: Int = 10
var rowNumber: NSInteger = -1
var isPopoverDisplayed: Bool = false
@ -137,7 +137,7 @@ class TimezoneCellView: NSTableCellView {
return
}
let newFontSize = CGFloat(TimezoneCellView.minimumFontSizeForLabel + (userFontSize.intValue * 1))
let newFontSize = CGFloat(TimezoneCellView.minimumFontSizeForLabel + (userFontSize.intValue * 1))
let newTimeFontSize = CGFloat(TimezoneCellView.minimumFontSizeForTime + (userFontSize.intValue * 2))
let fontManager = NSFontManager.shared

15
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -97,7 +97,7 @@ class StatusContainerView: NSView {
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle,
]
func containerWidth(for timezones: [Data]) -> CGFloat {
func containerWidth(for timezones: [Data], meetingTitle: String?, subtitle: String?) -> CGFloat {
var compressedWidth = timezones.reduce(0.0) { result, timezone -> CGFloat in
if let timezoneObject = TimezoneData.customObject(from: timezone) {
@ -118,7 +118,9 @@ class StatusContainerView: NSView {
}
if showUpcomingEventView {
compressedWidth += 70
let calculateMeetingHeaderSize = compactModeTimeFont.size(for: meetingTitle ?? "", width: 70, attributes: timeBasedAttributes)
let calculatedMeetingSubtitleSize = compactModeTimeFont.size(for: subtitle ?? "", width: 70, attributes: timeBasedAttributes)
compressedWidth += CGFloat(min(calculateMeetingHeaderSize.width, calculatedMeetingSubtitleSize.width) + 5.0)
}
let calculatedWidth = min(compressedWidth,
@ -126,7 +128,14 @@ class StatusContainerView: NSView {
return calculatedWidth
}
let statusItemWidth = containerWidth(for: timezones)
var title: String?
var meetingMetadata: String?
if let events = EventCenter.sharedCenter().eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: Date())], let upcomingEvent = EventCenter.sharedCenter().nextOccuring(events) {
title = upcomingEvent.event.title
meetingMetadata = upcomingEvent.metadataForMeeting()
}
let statusItemWidth = containerWidth(for: timezones, meetingTitle: title, subtitle: meetingMetadata)
let frame = NSRect(x: 0, y: 0, width: statusItemWidth, height: 30)
super.init(frame: frame)

4
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -247,7 +247,7 @@ class StatusItemHandler: NSObject {
func updateCompactMenubar() {
let filteredEvents = EventCenter.sharedCenter().filteredEvents
let calendar = EventCenter.sharedCenter().autoupdatingCalendar
let upcomingEvent = menubarTitleHandler.checkForUpcomingEvents(filteredEvents, calendar: calendar)
let upcomingEvent = menubarTitleHandler.checkForUpcomingEvents(filteredEvents, calendar: calendar)
if upcomingEvent != nil {
// Iterate and see if we're showing the calendar item view
let upcomingEventView = retrieveUpcomingEventStatusView()
@ -256,7 +256,7 @@ class StatusItemHandler: NSObject {
constructCompactView(with: true)
}
}
if let upcomingEventView = retrieveUpcomingEventStatusView(), upcomingEvent == nil {
upcomingEventView.removeFromSuperview()
constructCompactView() // So that Status Container View reclaims the space

Loading…
Cancel
Save