add stubs for adding MatchView
This commit is contained in:
@@ -16,19 +16,16 @@ class MatchView: NSView {
|
||||
@IBOutlet weak var team2name: NSTextField!
|
||||
@IBOutlet weak var team2score: NSTextField!
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
// Drawing code here.
|
||||
}
|
||||
|
||||
func updateView(with match: Match) {
|
||||
if !match.ongoing {
|
||||
self.ongoing.isHidden = true
|
||||
func updateView(for match: Match) {
|
||||
DispatchQueue.main.async {
|
||||
if !match.ongoing {
|
||||
self.ongoing.isHidden = true
|
||||
}
|
||||
}
|
||||
self.league.stringValue = match.league
|
||||
self.team1name.stringValue = match.team1name
|
||||
self.team1score.stringValue = match.team1score
|
||||
self.team2name.stringValue = match.team2name
|
||||
self.team2score.stringValue = match.team2score
|
||||
|
||||
// self.team1name.stringValue = match.team1name
|
||||
// self.team1score.stringValue = match.team1score
|
||||
// self.team2name.stringValue = match.team2name
|
||||
// self.team2score.stringValue = match.team2score
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
statusBarItem.image = icon
|
||||
statusBarItem.menu = statusBar
|
||||
statusBar.addItem(NSMenuItem.init(title: "Refresh", action: #selector(refreshClicked), keyEquivalent: ""))
|
||||
statusBar.addItem(NSMenuItem.init(title: "Set MatchView", action: #selector(updateView), keyEquivalent: ""))
|
||||
statusBar.addItem(NSMenuItem.init(title: "Quit", action: #selector(quitClicked), keyEquivalent: ""))
|
||||
for item in statusBar.items {
|
||||
item.target = self
|
||||
@@ -44,6 +45,7 @@ class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
for match in matches {
|
||||
let newItem = NSMenuItem.init(title: match.league + match.team1name + match.team1score + ":" + match.team2score + match.team2name, action: nil, keyEquivalent: "")
|
||||
newItem.tag = 1
|
||||
newItem.target = self
|
||||
statusBar.addItem(newItem)
|
||||
}
|
||||
}
|
||||
@@ -56,6 +58,14 @@ class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
}
|
||||
}
|
||||
|
||||
@objc func updateView() {
|
||||
for item in statusBar.items {
|
||||
if item.tag == 1 {
|
||||
item.view? = MatchView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func quitClicked(_ sender: NSMenuItem) {
|
||||
NSApplication.shared.terminate(self)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user