Browse Source

Swiftformat.

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

3
Clocker/ClockerUnitTests/ThemerTests.swift

@ -231,7 +231,7 @@ class ThemerTests: XCTestCase {
// Symbol images were introduced in 11.0; Clocker still supports 10.13+ so few asserts below that rely on symbol images will fail. // 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)) let eligibleOSVersion = ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 11, minorVersion: 0, patchVersion: 0))
if (eligibleOSVersion) { if eligibleOSVersion {
XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectations.expectedShutdownImageName) XCTAssertEqual(subject.shutdownImage().accessibilityDescription, expectations.expectedShutdownImageName)
XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectations.expectedPreferenceImageName) XCTAssertEqual(subject.preferenceImage().accessibilityDescription, expectations.expectedPreferenceImageName)
XCTAssertEqual(subject.pinImage().accessibilityDescription, expectations.expectedPinImageName) XCTAssertEqual(subject.pinImage().accessibilityDescription, expectations.expectedPinImageName)
@ -262,6 +262,5 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.menubarOnboardingImage().name(), expectations.expectedMenubarOnboardingImage) XCTAssertEqual(subject.menubarOnboardingImage().name(), expectations.expectedMenubarOnboardingImage)
XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectations.expectedExtraOptionsHighlightedImage) XCTAssertEqual(subject.extraOptionsHighlightedImage().name(), expectations.expectedExtraOptionsHighlightedImage)
XCTAssertEqual(subject.popoverAppearance(), expectations.expectedPopoverApperarance) XCTAssertEqual(subject.popoverAppearance(), expectations.expectedPopoverApperarance)
} }
} }

4
Clocker/Panel/UI/TimezoneCellView.swift

@ -13,8 +13,8 @@ class TimezoneCellView: NSTableCellView {
@IBOutlet var sunriseImage: NSImageView! @IBOutlet var sunriseImage: NSImageView!
@IBOutlet var currentLocationIndicator: NSImageView! @IBOutlet var currentLocationIndicator: NSImageView!
static private let minimumFontSizeForTime: Int = 11 private static let minimumFontSizeForTime: Int = 11
static private let minimumFontSizeForLabel: Int = 10 private static let minimumFontSizeForLabel: Int = 10
var rowNumber: NSInteger = -1 var rowNumber: NSInteger = -1
var isPopoverDisplayed: Bool = false var isPopoverDisplayed: Bool = false

15
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -97,7 +97,7 @@ class StatusContainerView: NSView {
NSAttributedString.Key.paragraphStyle: defaultParagraphStyle, 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 var compressedWidth = timezones.reduce(0.0) { result, timezone -> CGFloat in
if let timezoneObject = TimezoneData.customObject(from: timezone) { if let timezoneObject = TimezoneData.customObject(from: timezone) {
@ -118,7 +118,9 @@ class StatusContainerView: NSView {
} }
if showUpcomingEventView { 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, let calculatedWidth = min(compressedWidth,
@ -126,7 +128,14 @@ class StatusContainerView: NSView {
return calculatedWidth 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) let frame = NSRect(x: 0, y: 0, width: statusItemWidth, height: 30)
super.init(frame: frame) super.init(frame: frame)

Loading…
Cancel
Save