Skip to content

Commit 2bb7666

Browse files
author
Vincent Eichhorn
committed
refactoringggg klingeling
1 parent dff0d9f commit 2bb7666

10 files changed

+120
-154
lines changed

src/SpotifyConnect/SPOCApiAlbum.class.st

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ SPOCApiAlbum >> getAlbumWithID: aString [
5656

5757
{
5858
#category : #response,
59-
#'squeak_changestamp' : 'RK 7/7/2024 13:53'
59+
#'squeak_changestamp' : 'VE 7/8/2024 18:40'
6060
}
6161
SPOCApiAlbum >> tinkerReponseContent: aContentStream [
6262

@@ -65,7 +65,6 @@ SPOCApiAlbum >> tinkerReponseContent: aContentStream [
6565
tracks := OrderedCollection new.
6666
index := 0.
6767
(content at: #items)
68-
do: [:anItem | tracks add: ((self tinkerTrack: anItem) offset: index + 1).
69-
index := index + 1].
68+
do: [:anItem | tracks add: (self tinkerTrack: anItem)].
7069
^ tracks
7170
]

src/SpotifyConnect/SPOCApiPlaylist.class.st

+3-5
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ SPOCApiPlaylist >> getPlaylistWithID: aString [
5656

5757
{
5858
#category : #response,
59-
#'squeak_changestamp' : 'RK 7/7/2024 13:53'
59+
#'squeak_changestamp' : 'VE 7/8/2024 18:39'
6060
}
6161
SPOCApiPlaylist >> tinkerReponseContent: aContentStream [
6262

63-
| content tracks index |
63+
| content tracks |
6464
content := Json readFrom: aContentStream readStream.
6565
tracks := OrderedCollection new.
66-
index := 0.
6766
(content at: #items)
68-
do: [:anItem | tracks add: ((self tinkerTrack: (anItem at: #track)) offset: index + 1).
69-
index := index + 1].
67+
do: [:anItem | tracks add: (self tinkerTrack: (anItem at: #track))].
7068
^ tracks
7169
]

src/SpotifyConnect/SPOCApiSearch.class.st

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SPOCApiSearch >> search: aString withFilter: aFilter [
7070

7171
{
7272
#category : #response,
73-
#'squeak_changestamp' : 'VE 7/8/2024 16:43'
73+
#'squeak_changestamp' : 'VE 7/8/2024 18:38'
7474
}
7575
SPOCApiSearch >> tinkerReponseContent: aContentStream [
7676

@@ -83,6 +83,5 @@ SPOCApiSearch >> tinkerReponseContent: aContentStream [
8383
do: [:anAlbum | results add: (self tinkerAlbum: anAlbum)].
8484
(self contentItemsAt: #playlists in: content)
8585
do: [:aPlaylist | results add: (self tinkerPlaylist: aPlaylist)].
86-
results withIndexDo: [:aDataPiece :anIndex | aDataPiece offset: anIndex].
8786
^ results
8887
]

src/SpotifyConnect/SPOCDataPiece.class.st

-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Class {
88
'id',
99
'image',
1010
'name',
11-
'offset',
1211
'hasTertiaryText'
1312
],
1413
#category : #SpotifyConnect,
@@ -123,25 +122,6 @@ SPOCDataPiece >> name: aString [
123122
name := aString
124123
]
125124

126-
{
127-
#category : #accessing,
128-
#'squeak_changestamp' : 'TL 7/7/2024 02:32'
129-
}
130-
SPOCDataPiece >> offset [
131-
"Offset within a search result, album or playlist"
132-
133-
^ offset
134-
]
135-
136-
{
137-
#category : #accessing,
138-
#'squeak_changestamp' : 'RK 6/16/2024 13:59'
139-
}
140-
SPOCDataPiece >> offset: aNumber [
141-
142-
offset := aNumber
143-
]
144-
145125
{
146126
#category : #'event handling',
147127
#'squeak_changestamp' : 'RK 6/16/2024 12:10'

src/SpotifyConnect/SPOCPlayer.class.st

+35-42
Original file line numberDiff line numberDiff line change
@@ -54,60 +54,48 @@ SPOCPlayer class >> previousIconPath [
5454

5555
{
5656
#category : #initialization,
57-
#'squeak_changestamp' : 'VE 6/10/2024 22:27'
57+
#'squeak_changestamp' : 'VE 7/8/2024 18:51'
5858
}
5959
SPOCPlayer >> attachButton: anIcon [
6060

61-
self button: (SPOCClickable
62-
newUsing: anIcon
63-
onClick: [:anEvent | self executeButtonFunction: anIcon]);
61+
self button: (SPOCClickable newUsing: anIcon onClick: [:anEvent | self executeButtonFunction: anIcon]);
6462
addMorph: self button
6563
]
6664

6765
{
6866
#category : #initialization,
69-
#'squeak_changestamp' : 'TL 6/18/2024 23:35'
67+
#'squeak_changestamp' : 'VE 7/8/2024 18:51'
7068
}
7169
SPOCPlayer >> attachNextButton [
7270

73-
self nextIcon: (SPOCIcon new
74-
iconAsset: self class nextIconPath;
75-
color: Color transparent;
76-
yourself);
77-
attachButton: self nextIcon;
78-
addMorph: (Morph new
71+
self nextIcon: (SPOCIcon new iconAsset: self class nextIconPath;
7972
color: Color transparent;
80-
extent: 15 @ self button height;
81-
yourself)
73+
yourself);
74+
attachButton: self nextIcon;
75+
addMorph: self spacerMorph.
8276
]
8377

8478
{
8579
#category : #initialization,
86-
#'squeak_changestamp' : 'TL 6/18/2024 23:35'
80+
#'squeak_changestamp' : 'VE 7/8/2024 18:51'
8781
}
8882
SPOCPlayer >> attachPlayPauseButton [
8983

90-
self playPauseIcon: (SPOCIcon new
91-
iconAsset: self class playIconPath;
92-
yourself);
84+
self playPauseIcon: (SPOCIcon new iconAsset: self class playIconPath);
9385
attachButton: self playPauseIcon;
94-
addMorph: (Morph new
95-
color: Color transparent;
96-
extent: 15 @ self button height;
97-
yourself);
86+
addMorph: self spacerMorph;
9887
updatePlayPauseIcon
9988
]
10089

10190
{
10291
#category : #initialization,
103-
#'squeak_changestamp' : 'TL 6/18/2024 23:36'
92+
#'squeak_changestamp' : 'VE 7/8/2024 18:51'
10493
}
10594
SPOCPlayer >> attachPreviousButton [
10695

107-
self previousIcon: (SPOCIcon new
108-
iconAsset: self class previousIconPath;
109-
color: Color transparent;
110-
yourself);
96+
self previousIcon: (SPOCIcon new iconAsset: self class previousIconPath;
97+
color: Color transparent;
98+
yourself);
11199
attachButton: self previousIcon
112100
]
113101

@@ -239,23 +227,21 @@ SPOCPlayer >> nextIcon: anObject [
239227

240228
{
241229
#category : #'api-call',
242-
#'squeak_changestamp' : 'VE 6/26/2024 14:41'
230+
#'squeak_changestamp' : 'VE 7/8/2024 18:48'
243231
}
244232
SPOCPlayer >> pause [
245233

246-
SPOCApiPause new
247-
authorizer: self app auth;
234+
SPOCApiPause new authorizer: self app auth;
248235
pauseOn: self deviceID
249236
]
250237

251238
{
252239
#category : #'api-call',
253-
#'squeak_changestamp' : 'VE 6/26/2024 14:41'
240+
#'squeak_changestamp' : 'VE 7/8/2024 18:48'
254241
}
255242
SPOCPlayer >> play [
256243

257-
SPOCApiPlay new
258-
authorizer: self app auth;
244+
SPOCApiPlay new authorizer: self app auth;
259245
playOn: self deviceID
260246
]
261247

@@ -297,30 +283,37 @@ SPOCPlayer >> previousIcon: anObject [
297283

298284
{
299285
#category : #'api-call',
300-
#'squeak_changestamp' : 'VE 7/8/2024 18:26'
286+
#'squeak_changestamp' : 'VE 7/8/2024 18:48'
301287
}
302288
SPOCPlayer >> skipToNext [
303289

304-
SPOCApiNext new
305-
authorizer: self app auth;
306-
skipToNextOn: self deviceID;
307-
yourself.
290+
SPOCApiNext new authorizer: self app auth;
291+
skipToNextOn: self deviceID.
308292
self app updatePlaybackState
309293
]
310294

311295
{
312296
#category : #'api-call',
313-
#'squeak_changestamp' : 'VE 7/8/2024 18:27'
297+
#'squeak_changestamp' : 'VE 7/8/2024 18:48'
314298
}
315299
SPOCPlayer >> skipToPrevious [
316300

317-
SPOCApiPrevious new
318-
authorizer: self app auth;
319-
skipToPreviousOn: self deviceID;
320-
yourself.
301+
SPOCApiPrevious new authorizer: self app auth;
302+
skipToPreviousOn: self deviceID.
321303
self app updatePlaybackState
322304
]
323305

306+
{
307+
#category : #initialization,
308+
#'squeak_changestamp' : 'VE 7/8/2024 18:52'
309+
}
310+
SPOCPlayer >> spacerMorph [
311+
312+
^ Morph new color: Color transparent;
313+
extent: SPOCStyle defaultMargin @ self button height;
314+
yourself
315+
]
316+
324317
{
325318
#category : #actions,
326319
#'squeak_changestamp' : 'VE 6/26/2024 14:41'

src/SpotifyConnect/SPOCRecentlyPlayed.class.st

+6-11
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,13 @@ SPOCRecentlyPlayed class >> trackLimit [
5050

5151
{
5252
#category : #building,
53-
#'squeak_changestamp' : 'VK 7/7/2024 14:30'
53+
#'squeak_changestamp' : 'VE 7/8/2024 18:43'
5454
}
55-
SPOCRecentlyPlayed >> buildButton [
55+
SPOCRecentlyPlayed >> attachButton [
5656

57-
| text button |
57+
| text |
5858
text := SPOCBoxedTextWithIcon newWithText: 'Recently Played' withIcon: self class recentlyPlayedIconPath.
59-
button := Morph new color: Color transparent;
60-
addMorph: text;
61-
yourself.
62-
button extent: 0@0;
63-
extent: button fullBounds extent.
64-
self addMorph: (SPOCClickable newUsing: button onClick: [:anEvent | self getRecentlyPlayed])
59+
self addMorph: (SPOCClickable newUsing: text onClick: [:anEvent | self getRecentlyPlayed])
6560
]
6661

6762
{
@@ -82,7 +77,7 @@ SPOCRecentlyPlayed >> getRecentlyPlayed [
8277

8378
{
8479
#category : #initialization,
85-
#'squeak_changestamp' : 'RK 6/15/2024 16:41'
80+
#'squeak_changestamp' : 'VE 7/8/2024 18:43'
8681
}
8782
SPOCRecentlyPlayed >> initialize [
8883

@@ -92,7 +87,7 @@ SPOCRecentlyPlayed >> initialize [
9287
color: Color transparent;
9388
items: OrderedCollection new;
9489
results: OrderedCollection new;
95-
buildButton;
90+
attachButton;
9691
extendFully;
9792
yourself
9893
]

src/SpotifyConnect/SPOCRefresh.class.st

+3-7
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ SPOCRefresh class >> refreshIconPath [
2323

2424
{
2525
#category : #initialization,
26-
#'squeak_changestamp' : 'VE 7/2/2024 18:46'
26+
#'squeak_changestamp' : 'VE 7/8/2024 18:42'
2727
}
2828
SPOCRefresh >> attachButton [
2929

30-
self icon: (SPOCIcon new
31-
iconAsset: self class refreshIconPath;
32-
yourself);
33-
button: (SPOCClickable
34-
newUsing: self icon
35-
onClick: [:anEvent | self refresh]);
30+
self icon: (SPOCIcon new iconAsset: self class refreshIconPath);
31+
button: (SPOCClickable newUsing: self icon onClick: [:anEvent | self refresh]);
3632
addMorph: self button
3733
]
3834

src/SpotifyConnect/SPOCResultList.class.st

+18-8
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ Class {
1717

1818
{
1919
#category : #building,
20-
#'squeak_changestamp' : 'VE 6/10/2024 18:11'
20+
#'squeak_changestamp' : 'VE 7/8/2024 18:55'
2121
}
22-
SPOCResultList >> buildResultList [
22+
SPOCResultList >> attachResultList [
2323

24-
self buildScrollablePanel;
24+
self attachScrollablePanel;
2525
buildTitle;
2626
extendFully
2727
]
2828

2929
{
3030
#category : #building,
31-
#'squeak_changestamp' : 'VE 6/10/2024 19:09'
31+
#'squeak_changestamp' : 'VE 7/8/2024 18:55'
3232
}
33-
SPOCResultList >> buildScrollablePanel [
33+
SPOCResultList >> attachScrollablePanel [
3434

3535
self scrollablePanel: (SPOCScrollablePanel new
3636
hResizing: #spaceFill;
@@ -55,7 +55,7 @@ SPOCResultList >> buildTitle [
5555

5656
{
5757
#category : #initialization,
58-
#'squeak_changestamp' : 'VE 7/8/2024 18:31'
58+
#'squeak_changestamp' : 'VE 7/8/2024 18:55'
5959
}
6060
SPOCResultList >> initialize [
6161

@@ -70,7 +70,7 @@ SPOCResultList >> initialize [
7070
wrapCentering: #topLeft;
7171
vResizing: #spaceFill;
7272
hResizing: #spaceFill;
73-
buildResultList
73+
attachResultList
7474
]
7575

7676
{
@@ -102,15 +102,25 @@ SPOCResultList >> needsActiveDevice [
102102

103103
{
104104
#category : #updating,
105-
#'squeak_changestamp' : 'VE 7/8/2024 18:27'
105+
#'squeak_changestamp' : 'VE 7/8/2024 18:46'
106106
}
107107
SPOCResultList >> onItemClicked: anItem [
108108

109109
(self isDisabled and: (anItem dataPiece isKindOf: SPOCTrack)) ifTrue: [self showPopUp. ^ self].
110+
self resetHighlightColors.
110111
anItem highlightPrimaryTextColor.
111112
anItem dataPiece onClick: self app
112113
]
113114

115+
{
116+
#category : #updating,
117+
#'squeak_changestamp' : 'VE 7/8/2024 18:47'
118+
}
119+
SPOCResultList >> resetHighlightColors [
120+
121+
self items do: [:anItem | anItem wrappee resetPrimaryTextColor].
122+
]
123+
114124
{
115125
#category : #accessing,
116126
#'squeak_changestamp' : 'RK 6/7/2024 11:01'

0 commit comments

Comments
 (0)