Skip to content

Commit

Permalink
fix: check
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentakoong committed Mar 1, 2023
1 parent 70da5fc commit 658c8a8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions MusicBar/StatusBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class StatusBar: NSObject {
}
}

func getCheck(_ t: String,_ a: String) -> String {
func getCheck(_ t: String,_ a: String) -> String? {
let t = t.trimmingCharacters(in: .whitespaces)
let a = a.trimmingCharacters(in: .whitespaces)

Expand All @@ -55,7 +55,7 @@ class StatusBar: NSObject {
} else if(a != "") {
return "Song by \(a)"
} else {
return ""
return nil
}
}

Expand All @@ -82,16 +82,19 @@ class StatusBar: NSObject {
let songTitleCheck = self.getSongTitle(songTitle)
let songArtistCheck = self.getArtist(songArtist)

let check = getCheck(songTitleCheck, songArtistCheck)

let titleCombined = " " + getCheck(songTitleCheck, songArtistCheck)

if #available(macOS 11.0, *) {
button.title = titleCombined
}
else {
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.white]
let attributedText = NSAttributedString(string: titleCombined, attributes: attributes)
button.attributedTitle = attributedText
if (check != nil) {
let titleCombined = " " + (check ?? "")

if #available(macOS 11.0, *) {
button.title = titleCombined
}
else {
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.white]
let attributedText = NSAttributedString(string: titleCombined, attributes: attributes)
button.attributedTitle = attributedText
}
}

button.image = resized
Expand Down

0 comments on commit 658c8a8

Please sign in to comment.