-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c394eb
commit 01c50c3
Showing
9 changed files
with
103 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// StatsDisplay.swift | ||
// Covid-19 Status | ||
// | ||
// Created by Marcin Gajda on 03/04/2020. | ||
// Copyright © 2020 Marcin Gajda. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
class StatsDisplay: NSObject { | ||
var statusDisplay: NSStatusBarButton? | ||
var deltaDisplay: NSMenuItem? | ||
|
||
func setComponents(statusItem: NSStatusBarButton, deltaItem: NSMenuItem) { | ||
statusDisplay = statusItem | ||
deltaDisplay = deltaItem | ||
} | ||
|
||
func showStats(region: RegionStats) { | ||
let formatter = StatsFormatter(stats: region) | ||
|
||
DispatchQueue.main.async { | ||
self.statusDisplay?.attributedTitle = formatter.getRegionStatus() | ||
self.statusDisplay?.toolTip = formatter.getTooltip() | ||
self.deltaDisplay?.title = formatter.getRegionDelta() | ||
} | ||
} | ||
|
||
func showError(message: String?) { | ||
let error = message ?? NSLocalizedString("unknown cause", comment: "") | ||
|
||
DispatchQueue.main.async { | ||
self.statusDisplay?.attributedTitle = menuBarTextFormatter( | ||
label: NSLocalizedString("COVID-19 Status: Error", comment: "") | ||
) | ||
self.statusDisplay?.toolTip = error | ||
self.deltaDisplay?.title = error | ||
} | ||
} | ||
|
||
func showLoading() { | ||
DispatchQueue.main.async { | ||
self.statusDisplay?.attributedTitle = menuBarTextFormatter( | ||
label: NSLocalizedString("Loading...", comment: "") | ||
) | ||
self.statusDisplay?.toolTip = NSLocalizedString("COVID-19 Status", comment: "") | ||
self.deltaDisplay?.title = NSLocalizedString("Loading...", comment: "") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters