Skip to content

Commit dff0d9f

Browse files
author
Vincent Eichhorn
committed
refacotring highlighting in result list
1 parent 4b0dea8 commit dff0d9f

8 files changed

+153
-192
lines changed

src/SpotifyConnect/SPOCApp.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,13 @@ SPOCApp >> topPanelContent [
588588

589589
{
590590
#category : #updating,
591-
#'squeak_changestamp' : 'TL 7/7/2024 01:51'
591+
#'squeak_changestamp' : 'VE 7/8/2024 18:17'
592592
}
593593
SPOCApp >> updatePlaybackState [
594594

595595
| playbackState |
596596
playbackState := self getPlaybackState.
597+
(playbackState class = SPOCApiEndpointResult) ifTrue: [^ self].
597598
self componentsForUpdatingPlaybackState
598599
do: [:aComponent | aComponent updatePlaybackState: playbackState]
599600
]

src/SpotifyConnect/SPOCBoxedTextWithIcon.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ SPOCBoxedTextWithIcon class >> iconPadding [
1919

2020
{
2121
#category : #constructor,
22-
#'squeak_changestamp' : 'TL 7/8/2024 17:09'
22+
#'squeak_changestamp' : 'VE 7/8/2024 17:24'
2323
}
2424
SPOCBoxedTextWithIcon class >> newWithText: aString withIcon: anAssetPath [
2525

2626
^ SPOCBoxedTextWithIcon new contents: (' ', aString);
27-
position: self class iconPadding @ 0;
27+
position: self iconPadding @ 0;
2828
withAssetPath: anAssetPath;
2929
yourself
3030
]

src/SpotifyConnect/SPOCPlayer.class.st

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,29 +297,27 @@ SPOCPlayer >> previousIcon: anObject [
297297

298298
{
299299
#category : #'api-call',
300-
#'squeak_changestamp' : 'RK 7/7/2024 14:20'
300+
#'squeak_changestamp' : 'VE 7/8/2024 18:26'
301301
}
302302
SPOCPlayer >> skipToNext [
303303

304304
SPOCApiNext new
305305
authorizer: self app auth;
306306
skipToNextOn: self deviceID;
307307
yourself.
308-
self app resultList updateHighlightedTrackWithOffset: 1.
309308
self app updatePlaybackState
310309
]
311310

312311
{
313312
#category : #'api-call',
314-
#'squeak_changestamp' : 'RK 7/7/2024 14:20'
313+
#'squeak_changestamp' : 'VE 7/8/2024 18:27'
315314
}
316315
SPOCPlayer >> skipToPrevious [
317316

318317
SPOCApiPrevious new
319318
authorizer: self app auth;
320319
skipToPreviousOn: self deviceID;
321320
yourself.
322-
self app resultList updateHighlightedTrackWithOffset: -1.
323321
self app updatePlaybackState
324322
]
325323

src/SpotifyConnect/SPOCResultList.class.st

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,12 @@ Class {
99
'titleMorph',
1010
'results',
1111
'items',
12-
'scrollablePanel',
13-
'playingOffset'
12+
'scrollablePanel'
1413
],
1514
#category : #'SpotifyConnect-UI',
1615
#'squeak_changestamp' : 'OW 7/4/2024 12:12'
1716
}
1817

19-
{
20-
#category : #updating,
21-
#'squeak_changestamp' : 'RK 7/7/2024 15:36'
22-
}
23-
SPOCResultList >> addHighlightAt: aNumber [
24-
25-
(self items at: aNumber) wrappee togglePrimaryTextColor
26-
]
27-
2818
{
2919
#category : #building,
3020
#'squeak_changestamp' : 'VE 6/10/2024 18:11'
@@ -65,7 +55,7 @@ SPOCResultList >> buildTitle [
6555

6656
{
6757
#category : #initialization,
68-
#'squeak_changestamp' : 'RK 7/7/2024 13:51'
58+
#'squeak_changestamp' : 'VE 7/8/2024 18:31'
6959
}
7060
SPOCResultList >> initialize [
7161

@@ -74,7 +64,6 @@ SPOCResultList >> initialize [
7464
self color: Color transparent;
7565
results: OrderedCollection new;
7666
items: OrderedCollection new;
77-
playingOffset: -1;
7867
layoutPolicy: TableLayout new;
7968
listDirection: #topToBottom;
8069
listCentering: #topLeft;
@@ -113,42 +102,15 @@ SPOCResultList >> needsActiveDevice [
113102

114103
{
115104
#category : #updating,
116-
#'squeak_changestamp' : 'RK 7/7/2024 14:06'
105+
#'squeak_changestamp' : 'VE 7/8/2024 18:27'
117106
}
118107
SPOCResultList >> onItemClicked: anItem [
119108

120109
(self isDisabled and: (anItem dataPiece isKindOf: SPOCTrack)) ifTrue: [self showPopUp. ^ self].
121-
self updateHighlightedTrackWithItem: anItem.
110+
anItem highlightPrimaryTextColor.
122111
anItem dataPiece onClick: self app
123112
]
124113

125-
{
126-
#category : #accessing,
127-
#'squeak_changestamp' : 'RK 7/7/2024 13:47'
128-
}
129-
SPOCResultList >> playingOffset [
130-
131-
^ playingOffset
132-
]
133-
134-
{
135-
#category : #accessing,
136-
#'squeak_changestamp' : 'RK 7/7/2024 13:47'
137-
}
138-
SPOCResultList >> playingOffset: aNumber [
139-
140-
playingOffset := aNumber
141-
]
142-
143-
{
144-
#category : #updating,
145-
#'squeak_changestamp' : 'RK 7/7/2024 14:47'
146-
}
147-
SPOCResultList >> removeHighlight [
148-
149-
(self items at: playingOffset) wrappee togglePrimaryTextColor
150-
]
151-
152114
{
153115
#category : #accessing,
154116
#'squeak_changestamp' : 'RK 6/7/2024 11:01'
@@ -233,51 +195,32 @@ SPOCResultList >> titleMorph: aSPOCBoldText [
233195

234196
{
235197
#category : #updating,
236-
#'squeak_changestamp' : 'RK 7/7/2024 15:41'
237-
}
238-
SPOCResultList >> updateHighlightedTrackWithItem: anItem [
239-
"This method is used when a track was clicked on"
240-
241-
((self playingOffset > 0) and: (self playingOffset <= self size))
242-
ifTrue: [(self items at: playingOffset) wrappee togglePrimaryTextColor].
243-
self playingOffset: anItem dataPiece offset.
244-
anItem togglePrimaryTextColor
245-
]
246-
247-
{
248-
#category : #updating,
249-
#'squeak_changestamp' : 'RK 7/7/2024 16:54'
250-
}
251-
SPOCResultList >> updateHighlightedTrackWithOffset: aNumber [
252-
"This method is used when the currently playing track was changed by the player"
253-
254-
| next |
255-
(self app searchbar filter = 'track')
256-
ifTrue: [^ self].
257-
next := playingOffset + aNumber.
258-
((self playingOffset > 0) and: (self playingOffset <= self size))
259-
ifTrue: [self removeHighlight].
260-
((next > 0) and: (next <= self size))
261-
ifTrue: [self addHighlightAt: next].
262-
self playingOffset: next
263-
]
264-
265-
{
266-
#category : #updating,
267-
#'squeak_changestamp' : 'RK 7/7/2024 13:56'
198+
#'squeak_changestamp' : 'VE 7/8/2024 18:31'
268199
}
269200
SPOCResultList >> updateItems [
270201

271202
self items isEmpty ifFalse: [self items removeAll].
272-
self playingOffset: -1.
273203
self results do: [:aResult |
274204
| item clickable |
275205
item := SPOCResultListItem newWith: aResult.
276206
clickable := SPOCClickable newUsing: item onClick: [:anEvent | self onItemClicked: item].
277207
clickable layoutPolicy: TableLayout new;
278208
hResizing: #spaceFill;
279209
vResizing: #shrinkWrap.
280-
self items add: clickable]
210+
self items add: clickable].
211+
self app updatePlaybackState.
212+
]
213+
214+
{
215+
#category : #updating,
216+
#'squeak_changestamp' : 'VE 7/8/2024 18:26'
217+
}
218+
SPOCResultList >> updatePlaybackState: aPlaybackState [
219+
220+
super updatePlaybackState: aPlaybackState.
221+
self items do: [:anItem |
222+
anItem wrappee resetPrimaryTextColor.
223+
(anItem wrappee dataPiece id = aPlaybackState track id) ifTrue: [anItem wrappee highlightPrimaryTextColor]]
281224
]
282225

283226
{

src/SpotifyConnect/SPOCResultListItem.class.st

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ SPOCResultListItem >> dataPiece: aDataPiece [
187187
dataPiece := aDataPiece
188188
]
189189

190+
{
191+
#category : #'as yet unclassified',
192+
#'squeak_changestamp' : 'VE 7/8/2024 18:26'
193+
}
194+
SPOCResultListItem >> highlightPrimaryTextColor [
195+
196+
self primaryText color: SPOCStyle spotifyGreen
197+
]
198+
190199
{
191200
#category : #accessing,
192201
#'squeak_changestamp' : 'RK 6/7/2024 11:08'
@@ -242,6 +251,15 @@ SPOCResultListItem >> primaryText: aSPOCText [
242251
primaryText := aSPOCText
243252
]
244253

254+
{
255+
#category : #'as yet unclassified',
256+
#'squeak_changestamp' : 'VE 7/8/2024 18:07'
257+
}
258+
SPOCResultListItem >> resetPrimaryTextColor [
259+
260+
self primaryText color: SPOCStyle spotifyWhite
261+
]
262+
245263
{
246264
#category : #'as yet unclassified',
247265
#'squeak_changestamp' : 'VE 6/10/2024 19:18'
@@ -286,14 +304,3 @@ SPOCResultListItem >> tertiaryText: aSPOCText [
286304

287305
tertiaryText := aSPOCText
288306
]
289-
290-
{
291-
#category : #'as yet unclassified',
292-
#'squeak_changestamp' : 'RK 7/7/2024 13:42'
293-
}
294-
SPOCResultListItem >> togglePrimaryTextColor [
295-
296-
(self primaryText color = SPOCStyle spotifyGreen)
297-
ifTrue: [self primaryText color: SPOCStyle spotifyWhite]
298-
ifFalse: [self primaryText color: SPOCStyle spotifyGreen]
299-
]

0 commit comments

Comments
 (0)