From 791e62c9e71bb563feb7351ee21e615359d5f1aa Mon Sep 17 00:00:00 2001 From: Viktor Kalvoda Date: Wed, 19 Jun 2024 16:35:57 +0200 Subject: [PATCH] made SPOCBoxedTextWithIcon --- .../SPOCBoxedTextWithIcon.class.st | 37 +++++++++++++++++++ .../SPOCRecentlyPlayed.class.st | 19 ++++++---- src/SpotifyConnect/SPOCStyle.class.st | 9 +++++ src/SpotifyConnect/SPOCSwitchDevice.class.st | 21 +---------- 4 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 src/SpotifyConnect/SPOCBoxedTextWithIcon.class.st diff --git a/src/SpotifyConnect/SPOCBoxedTextWithIcon.class.st b/src/SpotifyConnect/SPOCBoxedTextWithIcon.class.st new file mode 100644 index 0000000..4576236 --- /dev/null +++ b/src/SpotifyConnect/SPOCBoxedTextWithIcon.class.st @@ -0,0 +1,37 @@ +Class { + #name : #SPOCBoxedTextWithIcon, + #superclass : #SPOCBoxedText, + #category : #'SpotifyConnect-UI' +} + +{ + #category : #constructor, + #'squeak_changestamp' : 'VK 6/19/2024 16:21' +} +SPOCBoxedTextWithIcon class >> newWithText: aString withIcon: anAssetPath [ + + | text | + text := SPOCBoxedTextWithIcon new contents: aString; + position: SPOCStyle iconPadding @ 0; + withAssetPath: anAssetPath; + yourself. + ^ text +] + +{ + #category : #initialization, + #'squeak_changestamp' : 'VK 6/19/2024 16:23' +} +SPOCBoxedTextWithIcon >> initialize [ + + super initialize. +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'VK 6/19/2024 16:27' +} +SPOCBoxedTextWithIcon >> withAssetPath: anAssetPath [ + + self addMorph: (SPOCIcon new iconAsset: anAssetPath) +] diff --git a/src/SpotifyConnect/SPOCRecentlyPlayed.class.st b/src/SpotifyConnect/SPOCRecentlyPlayed.class.st index ecf9020..c675756 100644 --- a/src/SpotifyConnect/SPOCRecentlyPlayed.class.st +++ b/src/SpotifyConnect/SPOCRecentlyPlayed.class.st @@ -26,6 +26,15 @@ SPOCRecentlyPlayed class >> beforeTimestamp [ ^ DateAndTime current asUnixTime * 1000 ] +{ + #category : #'as yet unclassified', + #'squeak_changestamp' : 'VK 6/19/2024 16:32' +} +SPOCRecentlyPlayed class >> recentlyPlayedIconPath [ + + ^ '/assets/recently-played.png' +] + { #category : #'as yet unclassified', #'squeak_changestamp' : 'VK 6/1/2024 22:08' @@ -37,18 +46,14 @@ SPOCRecentlyPlayed class >> trackLimit [ { #category : #building, - #'squeak_changestamp' : 'VE 6/10/2024 22:07' + #'squeak_changestamp' : 'VK 6/19/2024 16:33' } SPOCRecentlyPlayed >> buildButton [ - | text icon button | - text := (SPOCBoxedText new contents: ' Recently Played'; - position: SPOCStyle recentlyPlayedPadding@0; - yourself). - icon := SPOCIcon new iconAsset: '/assets/recently-played.png'. + | text button | + text := SPOCBoxedTextWithIcon newWithText: ' Recently Played' withIcon: self class recentlyPlayedIconPath. button := Morph new color: Color transparent; addMorph: text; - addMorph: icon; yourself. button extent: 0@0; extent: button fullBounds extent. diff --git a/src/SpotifyConnect/SPOCStyle.class.st b/src/SpotifyConnect/SPOCStyle.class.st index 4014971..079fbda 100644 --- a/src/SpotifyConnect/SPOCStyle.class.st +++ b/src/SpotifyConnect/SPOCStyle.class.st @@ -85,6 +85,15 @@ SPOCStyle class >> gitRepoName [ ^ 'SpotifyConnect' ] +{ + #category : #'class variables', + #'squeak_changestamp' : 'VK 6/19/2024 16:07' +} +SPOCStyle class >> iconPadding [ + + ^ 8 +] + { #category : #'class variables', #'squeak_changestamp' : 'RK 6/9/2024 14:44' diff --git a/src/SpotifyConnect/SPOCSwitchDevice.class.st b/src/SpotifyConnect/SPOCSwitchDevice.class.st index 401a481..77e43dc 100644 --- a/src/SpotifyConnect/SPOCSwitchDevice.class.st +++ b/src/SpotifyConnect/SPOCSwitchDevice.class.st @@ -30,18 +30,12 @@ SPOCSwitchDevice class >> itemTextPadding [ { #category : #building, - #'squeak_changestamp' : 'TL 6/17/2024 20:23' + #'squeak_changestamp' : 'VK 6/19/2024 16:31' } SPOCSwitchDevice >> attachButton [ | button | - button := Morph new - color: Color transparent; - addMorph: self buttonText; - addMorph: (SPOCIcon new iconAsset: self class devicesIconPath); - yourself. - button extent: 0@0; - extent: button fullBounds extent. + button := SPOCBoxedTextWithIcon newWithText: ' Devices' withIcon: self class devicesIconPath. self addMorph: (SPOCClickable newUsing: button onClick: [:anEvent | self buttonClicked]) ] @@ -130,17 +124,6 @@ SPOCSwitchDevice >> buttonClicked [ ifFalse: [self currentDevices]] ] -{ - #category : #building, - #'squeak_changestamp' : 'VK 6/10/2024 19:10' -} -SPOCSwitchDevice >> buttonText [ - - ^ (SPOCBoxedText new contents: ' Devices'; - position: SPOCStyle devicesTextPadding@0; - yourself). -] - { #category : #'api-call', #'squeak_changestamp' : 'TL 6/17/2024 20:29'