1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
a672ef5978
Remove some unused code 2019-02-12 22:53:29 -05:00
a251fe18fe
Change colour of borders depending on dark/light mode 2019-02-12 22:43:38 -05:00
a61ecc6c40
Update screenshot 2019-02-12 22:13:03 -05:00
673f8b41ab
Improve display of blank albums
* Add dark and light blank album image variants
* Use CALayer to draw rounded corners and a tinted border on each album
  cover
2019-02-12 22:08:57 -05:00
61fdbff44e
Auto set width of albums and restrict queue view width 2019-02-12 21:34:39 -05:00
36 changed files with 124 additions and 80 deletions

View File

@ -179,6 +179,7 @@
E407861A2110CE6E006887B1 /* Persephone */ = { E407861A2110CE6E006887B1 /* Persephone */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E407861F2110CE70006887B1 /* Assets.xcassets */,
E408D3B7220DE8CC0006D9BE /* Extensions */, E408D3B7220DE8CC0006D9BE /* Extensions */,
E4D1B598220BA3C90026F233 /* Resources */, E4D1B598220BA3C90026F233 /* Resources */,
E4D1B597220BA3A20026F233 /* Controllers */, E4D1B597220BA3A20026F233 /* Controllers */,
@ -230,9 +231,7 @@
E408D3C3220E138B0006D9BE /* Views */ = { E408D3C3220E138B0006D9BE /* Views */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E40786212110CE70006887B1 /* Main.storyboard */,
E408D3C8220E341D0006D9BE /* AlbumItem.swift */, E408D3C8220E341D0006D9BE /* AlbumItem.swift */,
E408D3C9220E341D0006D9BE /* AlbumItem.xib */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -340,7 +339,8 @@
E4D1B598220BA3C90026F233 /* Resources */ = { E4D1B598220BA3C90026F233 /* Resources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E407861F2110CE70006887B1 /* Assets.xcassets */, E40786212110CE70006887B1 /* Main.storyboard */,
E408D3C9220E341D0006D9BE /* AlbumItem.xib */,
); );
path = Resources; path = Resources;
sourceTree = "<group>"; sourceTree = "<group>";

View File

@ -0,0 +1,35 @@
{
"images" : [
{
"idiom" : "universal"
},
{
"idiom" : "universal",
"filename" : "blankAlbumLight-1.pdf",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
]
},
{
"idiom" : "universal",
"filename" : "blankAlbumDark.pdf",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
]
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original",
"preserves-vector-representation" : true
}
}

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

View File

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 242 B

View File

Before

Width:  |  Height:  |  Size: 92 B

After

Width:  |  Height:  |  Size: 92 B

View File

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

View File

@ -10,8 +10,12 @@ import Cocoa
class AlbumViewController: NSViewController, class AlbumViewController: NSViewController,
NSCollectionViewDataSource, NSCollectionViewDataSource,
NSCollectionViewDelegate { NSCollectionViewDelegate,
NSCollectionViewDelegateFlowLayout {
var albums: [MPDClient.Album] = [] var albums: [MPDClient.Album] = []
var albumWidth: CGFloat = 0
let paddingWidth: CGFloat = 40
let gutterWidth: CGFloat = 20
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -24,6 +28,12 @@ class AlbumViewController: NSViewController,
) )
} }
override func viewWillLayout() {
super.viewWillLayout()
albumCollectionView.collectionViewLayout?.invalidateLayout()
}
@objc func updateAlbums(_ notification: Notification) { @objc func updateAlbums(_ notification: Notification) {
guard let albums = notification.userInfo?[Notification.albumsKey] as? [MPDClient.Album] guard let albums = notification.userInfo?[Notification.albumsKey] as? [MPDClient.Album]
else { return } else { return }
@ -51,5 +61,22 @@ class AlbumViewController: NSViewController,
return albumItem return albumItem
} }
func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, sizeForItemAt: IndexPath) -> NSSize {
let width = collectionView.frame.size.width
var divider: CGFloat = 1
var itemWidth: CGFloat = 0
repeat {
let totalPaddingWidth = paddingWidth * 2
let totalGutterWidth = (divider - 1) * (gutterWidth + 1)
itemWidth = (width - totalPaddingWidth - totalGutterWidth) / divider
divider = divider + 1
} while itemWidth > 180
let itemHeight = itemWidth + 39
return NSSize(width: itemWidth, height: itemHeight)
}
@IBOutlet var albumCollectionView: NSCollectionView! @IBOutlet var albumCollectionView: NSCollectionView!
} }

View File

@ -28,7 +28,7 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
queueView.columnAutoresizingStyle = .uniformColumnAutoresizingStyle queueView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
self, self,

View File

@ -110,7 +110,6 @@ class MPDClient {
} }
func sendCommand(command: Command) { func sendCommand(command: Command) {
print("Command:", command)
switch command { switch command {
// Transport commands // Transport commands
@ -199,43 +198,6 @@ class MPDClient {
delegate?.didLoadAlbums(mpdClient: self, albums: albums) delegate?.didLoadAlbums(mpdClient: self, albums: albums)
} }
func albumsForArtist(_ artist: String) -> [Album] {
var albums: [Album] = []
mpd_search_db_tags(self.connection, MPD_TAG_ALBUM)
mpd_search_add_tag_constraint(self.connection, MPD_OPERATOR_DEFAULT, MPD_TAG_ARTIST, artist)
mpd_search_commit(self.connection)
while let mpdAlbumPair = mpd_recv_pair_tag(self.connection, MPD_TAG_ALBUM) {
print(artist, "-", String(cString: mpdAlbumPair.pointee.value))
albums.append(Album(title: String(cString: mpdAlbumPair.pointee.value), artist: artist))
mpd_return_pair(self.connection, mpdAlbumPair)
}
return albums
}
func allArtists() -> [String] {
var artists: [String] = []
mpd_search_db_tags(self.connection, MPD_TAG_ARTIST)
mpd_search_commit(self.connection)
while let mpdArtistPair = mpd_recv_pair_tag(self.connection, MPD_TAG_ARTIST) {
artists.append(String(cString: mpdArtistPair.pointee.value))
mpd_return_pair(self.connection, mpdArtistPair)
}
return artists
}
func sendSearchDbTags(_ tagType: mpd_tag_type) {
mpd_search_db_tags(self.connection, tagType)
mpd_search_commit(self.connection)
while let mpdPair = mpd_recv_pair_tag(self.connection, tagType) {
print(String(cString: mpdPair.pointee.value))
mpd_return_pair(self.connection, mpdPair)
}
}
func noIdle() { func noIdle() {
mpd_send_noidle(connection) mpd_send_noidle(connection)
} }
@ -262,7 +224,6 @@ class MPDClient {
self.delegate?.didUpdateQueuePos(mpdClient: self, song: self.status!.song) self.delegate?.didUpdateQueuePos(mpdClient: self, song: self.status!.song)
} }
if !mpdIdle.isEmpty { if !mpdIdle.isEmpty {
print("Status")
self.idle() self.idle()
} }
} }

View File

@ -9,50 +9,52 @@
<customObject id="-2" userLabel="File's Owner" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"> <customObject id="-2" userLabel="File's Owner" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target">
<connections> <connections>
<outlet property="albumArtist" destination="5Uu-j1-qyT" id="2Et-tX-InT"/> <outlet property="albumArtist" destination="5Uu-j1-qyT" id="2Et-tX-InT"/>
<outlet property="albumCoverView" destination="Kfb-8f-ean" id="ZAL-jD-lHj"/>
<outlet property="albumTitle" destination="KEh-NL-c2W" id="SI3-hm-H2B"/> <outlet property="albumTitle" destination="KEh-NL-c2W" id="SI3-hm-H2B"/>
<outlet property="imageView" destination="Kfb-8f-ean" id="Ur0-hX-wJm"/>
<outlet property="view" destination="Hz6-mo-xeY" id="v7W-XA-Emc"/> <outlet property="view" destination="Hz6-mo-xeY" id="v7W-XA-Emc"/>
</connections> </connections>
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY"> <customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="160" height="207"/> <rect key="frame" x="0.0" y="0.0" width="128" height="167"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<imageView identifier="albumArtwork" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kfb-8f-ean"> <textField identifier="albumTitle" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KEh-NL-c2W">
<rect key="frame" x="0.0" y="45" width="160" height="162"/> <rect key="frame" x="-2" y="18" width="132" height="17"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="blankAlbum" id="FsA-JX-BFh"/>
</imageView>
<textField identifier="albumTitle" horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="KEh-NL-c2W">
<rect key="frame" x="-2" y="20" width="164" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="pDs-0t-e1j"> <textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="pDs-0t-e1j">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField identifier="albumArtist" horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="206" translatesAutoresizingMaskIntoConstraints="NO" id="5Uu-j1-qyT"> <textField identifier="albumArtist" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5Uu-j1-qyT">
<rect key="frame" x="-2" y="0.0" width="164" height="17"/> <rect key="frame" x="-2" y="0.0" width="132" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="yZn-e9-zyP"> <textFieldCell key="cell" lineBreakMode="truncatingTail" title="Label" id="yZn-e9-zyP">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<imageView identifier="albumArtwork" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Kfb-8f-ean">
<rect key="frame" x="0.0" y="39" width="128" height="128"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="blankAlbum" id="FsA-JX-BFh"/>
</imageView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="5Uu-j1-qyT" firstAttribute="trailing" secondItem="KEh-NL-c2W" secondAttribute="trailing" id="64z-uz-4nY"/> <constraint firstItem="5Uu-j1-qyT" firstAttribute="trailing" secondItem="KEh-NL-c2W" secondAttribute="trailing" id="64z-uz-4nY"/>
<constraint firstAttribute="bottom" secondItem="KEh-NL-c2W" secondAttribute="bottom" constant="20" symbolic="YES" id="8Kg-1r-wNp"/> <constraint firstAttribute="bottom" secondItem="KEh-NL-c2W" secondAttribute="bottom" constant="18" id="8Kg-1r-wNp"/>
<constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="JMi-4i-dgs"/> <constraint firstItem="Kfb-8f-ean" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="JMi-4i-dgs"/>
<constraint firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="KQC-Wz-Bsg"/> <constraint firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="KQC-Wz-Bsg"/>
<constraint firstItem="5Uu-j1-qyT" firstAttribute="leading" secondItem="KEh-NL-c2W" secondAttribute="leading" id="MUo-0i-fX9"/> <constraint firstItem="5Uu-j1-qyT" firstAttribute="leading" secondItem="KEh-NL-c2W" secondAttribute="leading" id="MUo-0i-fX9"/>
<constraint firstItem="Kfb-8f-ean" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Qbk-jx-zAi"/> <constraint firstItem="Kfb-8f-ean" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Qbk-jx-zAi"/>
<constraint firstItem="KEh-NL-c2W" firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="U0w-G4-ggX"/> <constraint firstItem="KEh-NL-c2W" firstAttribute="trailing" secondItem="Kfb-8f-ean" secondAttribute="trailing" id="U0w-G4-ggX"/>
<constraint firstItem="KEh-NL-c2W" firstAttribute="leading" secondItem="Kfb-8f-ean" secondAttribute="leading" id="V8r-Rc-Dx7"/> <constraint firstItem="KEh-NL-c2W" firstAttribute="leading" secondItem="Kfb-8f-ean" secondAttribute="leading" id="V8r-Rc-Dx7"/>
<constraint firstItem="KEh-NL-c2W" firstAttribute="top" secondItem="Kfb-8f-ean" secondAttribute="bottom" constant="8" symbolic="YES" id="XFx-sv-dpF"/>
<constraint firstAttribute="bottom" secondItem="5Uu-j1-qyT" secondAttribute="bottom" id="gci-4h-pDZ"/> <constraint firstAttribute="bottom" secondItem="5Uu-j1-qyT" secondAttribute="bottom" id="gci-4h-pDZ"/>
<constraint firstAttribute="bottom" secondItem="Kfb-8f-ean" secondAttribute="bottom" constant="39" id="sid-zJ-YMA"/>
</constraints> </constraints>
<point key="canvasLocation" x="-22" y="139.5"/> <point key="canvasLocation" x="-22" y="125.5"/>
</customView> </customView>
<collectionViewItem id="Qgu-aI-55A" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"/> <collectionViewItem id="Qgu-aI-55A" customClass="AlbumItem" customModule="Persephone" customModuleProvider="target"/>
</objects> </objects>

View File

@ -1,12 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "blankAlbum.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -737,7 +737,7 @@
<objects> <objects>
<splitViewController id="fnD-7K-pHK" sceneMemberID="viewController"> <splitViewController id="fnD-7K-pHK" sceneMemberID="viewController">
<splitViewItems> <splitViewItems>
<splitViewItem canCollapse="YES" holdingPriority="260" behavior="sidebar" id="CWo-v7-gd2"/> <splitViewItem holdingPriority="255" behavior="contentList" id="CWo-v7-gd2"/>
<splitViewItem id="y8g-4F-czS"/> <splitViewItem id="y8g-4F-czS"/>
</splitViewItems> </splitViewItems>
<splitView key="splitView" dividerStyle="thin" vertical="YES" id="g34-ef-XN0"> <splitView key="splitView" dividerStyle="thin" vertical="YES" id="g34-ef-XN0">
@ -762,23 +762,23 @@
<objects> <objects>
<viewController id="KIP-rq-4dM" customClass="QueueViewController" customModule="Persephone" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="KIP-rq-4dM" customClass="QueueViewController" customModule="Persephone" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="2su-YT-hba"> <view key="view" id="2su-YT-hba">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/> <rect key="frame" x="0.0" y="0.0" width="350" height="300"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S3o-nF-NN7"> <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S3o-nF-NN7">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/> <rect key="frame" x="0.0" y="0.0" width="350" height="300"/>
<clipView key="contentView" drawsBackground="NO" id="WI8-Pw-03L"> <clipView key="contentView" drawsBackground="NO" id="WI8-Pw-03L">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/> <rect key="frame" x="0.0" y="0.0" width="350" height="300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" indentationPerLevel="16" outlineTableColumn="0Co-uF-CCB" id="jEJ-jg-fll"> <outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="sourceList" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" indentationPerLevel="16" outlineTableColumn="0Co-uF-CCB" id="jEJ-jg-fll">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/> <rect key="frame" x="0.0" y="0.0" width="350" height="300"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/> <size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="_sourceListBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns> <tableColumns>
<tableColumn identifier="songTitleColumn" width="222" minWidth="128" maxWidth="1000" id="0Co-uF-CCB"> <tableColumn identifier="songTitleColumn" width="200" minWidth="128" maxWidth="1000" id="0Co-uF-CCB">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Title"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Title">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -792,7 +792,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
<prototypeCellViews> <prototypeCellViews>
<tableCellView identifier="queueHeadingCell" id="GOd-cg-juD"> <tableCellView identifier="queueHeadingCell" id="GOd-cg-juD">
<rect key="frame" x="1" y="1" width="222" height="17"/> <rect key="frame" x="1" y="1" width="200" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xgd-Cz-np3"> <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xgd-Cz-np3">
@ -807,7 +807,7 @@
</subviews> </subviews>
</tableCellView> </tableCellView>
<tableCellView identifier="songTitleCell" id="5rR-Gz-AcP"> <tableCellView identifier="songTitleCell" id="5rR-Gz-AcP">
<rect key="frame" x="1" y="20" width="222" height="17"/> <rect key="frame" x="1" y="20" width="200" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<imageView translatesAutoresizingMaskIntoConstraints="NO" id="o8i-cz-hIP"> <imageView translatesAutoresizingMaskIntoConstraints="NO" id="o8i-cz-hIP">
@ -818,7 +818,7 @@
<imageCell key="cell" refusesFirstResponder="YES" imageScaling="proportionallyDown" id="ckK-gW-Vhx"/> <imageCell key="cell" refusesFirstResponder="YES" imageScaling="proportionallyDown" id="ckK-gW-Vhx"/>
</imageView> </imageView>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i0h-bn-auJ"> <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i0h-bn-auJ">
<rect key="frame" x="25" y="0.0" width="197" height="17"/> <rect key="frame" x="25" y="0.0" width="175" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="ei8-1e-ErK"> <textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="ei8-1e-ErK">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -841,7 +841,7 @@
</tableCellView> </tableCellView>
</prototypeCellViews> </prototypeCellViews>
</tableColumn> </tableColumn>
<tableColumn identifier="songArtistColumn" width="222" minWidth="128" maxWidth="1000" id="SPM-QP-DX8"> <tableColumn identifier="songArtistColumn" width="144" minWidth="128" maxWidth="1000" id="SPM-QP-DX8">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Artist"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Artist">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@ -855,7 +855,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
<prototypeCellViews> <prototypeCellViews>
<tableCellView identifier="songArtistCell" id="JSk-Vc-Y7e"> <tableCellView identifier="songArtistCell" id="JSk-Vc-Y7e">
<rect key="frame" x="226" y="1" width="222" height="17"/> <rect key="frame" x="204" y="1" width="144" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tBe-Q9-3Rw"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tBe-Q9-3Rw">
@ -883,8 +883,12 @@
</subviews> </subviews>
<nil key="backgroundColor"/> <nil key="backgroundColor"/>
</clipView> </clipView>
<constraints>
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="500" id="tgW-46-U0V"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="ynf-58-b0B"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="7mx-v9-DSr"> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="7mx-v9-DSr">
<rect key="frame" x="0.0" y="284" width="450" height="16"/> <rect key="frame" x="0.0" y="284" width="350" height="16"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> </scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="p5z-C0-FUJ"> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="p5z-C0-FUJ">

View File

@ -9,9 +9,24 @@
import Cocoa import Cocoa
class AlbumItem: NSCollectionViewItem { class AlbumItem: NSCollectionViewItem {
let borderColorLight = NSColor.black.withAlphaComponent(0.1).cgColor
let borderColorDark = NSColor.white.withAlphaComponent(0.1).cgColor
var observer: NSKeyValueObservation?
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// Do view setup here. // Do view setup here.
albumCoverView.wantsLayer = true
albumCoverView.layer?.cornerRadius = 3
albumCoverView.layer?.borderWidth = 1
setAppearance()
if #available(OSX 10.14, *) {
observer = NSApp.observe(\.effectiveAppearance) { (app, _) in
self.setAppearance()
}
}
} }
func setAlbum(_ album: MPDClient.Album) { func setAlbum(_ album: MPDClient.Album) {
@ -19,6 +34,18 @@ class AlbumItem: NSCollectionViewItem {
albumArtist.stringValue = album.artist albumArtist.stringValue = album.artist
} }
func setAppearance() {
if #available(OSX 10.14, *) {
let darkMode = NSApp.effectiveAppearance.bestMatch(from:
[.darkAqua, .aqua]) == .darkAqua
albumCoverView.layer?.borderColor = darkMode ? borderColorDark : borderColorLight
} else {
albumCoverView.layer?.borderColor = borderColorLight
}
}
@IBOutlet var albumCoverView: NSImageView!
@IBOutlet var albumTitle: NSTextField! @IBOutlet var albumTitle: NSTextField!
@IBOutlet var albumArtist: NSTextField! @IBOutlet var albumArtist: NSTextField!
} }

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 168 KiB