mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
4 Commits
7d0c50a8b7
...
9f8f3a6ecf
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f8f3a6ecf | |||
| 034eb6dca5 | |||
| 47ad36f12a | |||
| da851365d6 |
@ -14,7 +14,7 @@ class AlbumViewItem: NSCollectionViewItem {
|
||||
|
||||
override var isSelected: Bool {
|
||||
didSet {
|
||||
albumCoverBox.layer?.borderWidth = isSelected ? 5 : 0
|
||||
setAppearance(selected: isSelected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,18 +22,20 @@ class AlbumViewItem: NSCollectionViewItem {
|
||||
super.viewDidLoad()
|
||||
|
||||
albumCoverView.wantsLayer = true
|
||||
albumCoverView.layer?.cornerRadius = 3
|
||||
albumCoverView.layer?.backgroundColor = NSColor.black.cgColor
|
||||
albumCoverView.layer?.cornerRadius = 4
|
||||
albumCoverView.layer?.borderWidth = 1
|
||||
albumCoverView.layer?.masksToBounds = true
|
||||
|
||||
albumCoverBox.wantsLayer = true
|
||||
albumCoverBox.layer?.cornerRadius = 5
|
||||
albumCoverBox.layer?.borderWidth = 0
|
||||
albumCoverBox.layer?.cornerRadius = 7
|
||||
albumCoverBox.layer?.borderWidth = 5
|
||||
|
||||
setAppearance()
|
||||
setAppearance(selected: false)
|
||||
|
||||
if #available(OSX 10.14, *) {
|
||||
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
|
||||
self.setAppearance()
|
||||
self.setAppearance(selected: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,16 +59,22 @@ class AlbumViewItem: NSCollectionViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
func setAppearance() {
|
||||
func setAppearance(selected isSelected: Bool) {
|
||||
guard let viewLayer = albumCoverView.layer,
|
||||
let boxLayer = albumCoverBox.layer
|
||||
else { return }
|
||||
|
||||
if #available(OSX 10.14, *) {
|
||||
let darkMode = NSApp.effectiveAppearance.bestMatch(from:
|
||||
[.darkAqua, .aqua]) == .darkAqua
|
||||
|
||||
albumCoverView.layer?.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
|
||||
albumCoverBox.layer?.borderColor = NSColor.controlAccentColor.cgColor
|
||||
viewLayer.borderColor = darkMode ? .albumBorderColorDark : .albumBorderColorLight
|
||||
boxLayer.borderColor = isSelected ? NSColor.controlAccentColor.cgColor : CGColor.clear
|
||||
boxLayer.backgroundColor = albumCoverBox.layer?.borderColor
|
||||
} else {
|
||||
albumCoverView.layer?.borderColor = .albumBorderColorLight
|
||||
albumCoverBox.layer?.borderColor = NSColor.selectedControlColor.cgColor
|
||||
viewLayer.borderColor = .albumBorderColorLight
|
||||
boxLayer.borderColor = isSelected ? NSColor.selectedControlColor.cgColor : CGColor.clear
|
||||
boxLayer.backgroundColor = albumCoverBox.layer?.borderColor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
import AppKit
|
||||
|
||||
class AlbumDetailView: NSViewController {
|
||||
var observer: NSKeyValueObservation?
|
||||
var album: Album?
|
||||
var dataSource = AlbumTracksDataSource()
|
||||
|
||||
@ -30,10 +31,17 @@ class AlbumDetailView: NSViewController {
|
||||
albumTracksView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
|
||||
|
||||
albumCoverView.wantsLayer = true
|
||||
albumCoverView.layer?.cornerRadius = 5
|
||||
albumCoverView.layer?.backgroundColor = NSColor.black.cgColor
|
||||
albumCoverView.layer?.cornerRadius = 6
|
||||
albumCoverView.layer?.borderWidth = 1
|
||||
albumCoverView.layer?.masksToBounds = true
|
||||
setAppearance()
|
||||
|
||||
if #available(OSX 10.14, *) {
|
||||
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
|
||||
self.setAppearance()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user