@@ -21,7 +21,7 @@ struct AlbumDetailView: View {
2121 . stretchable ( )
2222
2323 VStack ( alignment : . leading , spacing : Padding . xxl ) {
24- AlbumHeader ( entry : entry , size : . lg )
24+ AlbumHeaderSection ( entry : entry )
2525 AlbumDetailSection ( entry : entry , showMetadata : showMetadata )
2626 AlbumTrackSection ( tracks : vm . tracks )
2727 }
@@ -59,35 +59,45 @@ private struct AlbumCover: View {
5959 }
6060}
6161
62+ private struct AlbumHeaderSection : View {
63+ let entry : AlbumEntry
64+
65+ var body : some View {
66+ HStack ( alignment : . top ) {
67+ AlbumHeader ( entry : entry , size : . large )
68+
69+ Spacer ( )
70+
71+ Icon ( systemName : " star.fill " , size : 24 )
72+ . foregroundStyle ( . accent )
73+ . symbolEffect ( . bounce . up , options : . speed ( 2 ) , value : entry . isFavorited )
74+ . opacity ( entry . isFavorited ? 1 : 0 )
75+ }
76+ }
77+ }
78+
6279private struct AlbumDetailSection : View {
6380 let entry : AlbumEntry
6481 let showMetadata : Bool
6582
6683 var body : some View {
67- VStack ( alignment : . leading , spacing : Padding . xl ) {
68- SectionHeader ( " About " )
69- Section {
70- VStack ( spacing : Spacing . sm ) {
71- if let label = entry . labels . first {
72- AlbumDetailRow ( " Label " , label )
73- Divider ( )
74- }
75-
76- if let year = entry . year ? . description {
77- AlbumDetailRow ( " Released " , year )
78- Divider ( )
79- }
84+ ThemeSection {
85+ Section ( " About " ) {
86+ if let label = entry . labels . first {
87+ LabeledContent ( " Label " , value : label )
88+ }
8089
81- if showMetadata {
82- AlbumDetailRow ( " Recognized " , entry . selectedAt . abbreviated )
83- Divider ( )
90+ if let year = entry . year ? . description {
91+ LabeledContent ( " Released " , value : year )
92+ }
8493
85- LocationSection ( entry : entry )
86- . frame ( minHeight : 12 )
87- }
94+ if showMetadata {
95+ LabeledContent ( " Recognized " , value : entry . selectedAt . abbreviated )
96+ LocationSection ( entry : entry )
8897 }
8998 }
9099 }
100+ . labeledContentStyle ( . withThemeFont )
91101 }
92102}
93103
@@ -105,13 +115,12 @@ private struct LocationSection: View {
105115 var body : some View {
106116 switch entry . locationStatus {
107117 case . pending :
108- HStack {
109- Text ( " Location " ) . font ( . sligoilMicroBold ( . subheadline ) )
110- Spacer ( )
118+ LabeledContent {
111119 ProgressView ( )
120+ . controlSize ( . small )
121+ } label : {
122+ Text ( " Location " )
112123 }
113- . foregroundStyle ( . themePrimaryInverted )
114- . opacity ( 0.625 )
115124
116125 case . captured :
117126 if let location = entry . location {
@@ -121,23 +130,16 @@ private struct LocationSection: View {
121130 accuracyRadius : entry . locationHorizontalAccuracy ,
122131 )
123132 } label : {
124- Group {
125- if ( entry . locationHorizontalAccuracy ?? 0 ) >= 1_000 {
126- Text ( " Approximate Location " )
127- } else {
128- Text ( " Location " )
129- }
130- }
131- . font ( . sligoilMicroBold ( . subheadline ) )
133+ Text ( " Location " )
134+ . font ( . sligoilMicroBold ( . subheadline ) )
132135 }
133136 . disclosureGroupStyle ( . plain )
134- . opacity ( 0.625 )
135137 } else {
136- AlbumDetailRow ( " Location " , " No Location " )
138+ LabeledContent ( " Location " , value : " No Location " )
137139 }
138140
139141 case . denied , . unavailable :
140- AlbumDetailRow ( " Location " , " No Location " )
142+ LabeledContent ( " Location " , value : " No Location " )
141143 }
142144 }
143145}
@@ -153,8 +155,8 @@ private struct MapView: View {
153155 Map ( position : $position ) {
154156 if let accuracyRadius , accuracyRadius > 0 {
155157 MapCircle ( center : location . coordinate , radius : accuracyRadius )
156- . foregroundStyle ( . themeBlue . opacity ( 0.15 ) )
157- . stroke ( . themeBlue . opacity ( 0.55 ) , lineWidth : 1 )
158+ . foregroundStyle ( . themeBlue . opacity ( 0.25 ) )
159+ . stroke ( . themeBlue . opacity ( 0.5 ) , lineWidth : 1 )
158160 }
159161 Marker ( " Location " , coordinate : location . coordinate )
160162 }
@@ -193,43 +195,26 @@ private struct MapView: View {
193195 }
194196}
195197
196- private struct AlbumDetailRow : View {
197- let key : String
198- let value : String
199-
200- init ( _ key : String , _ value : String ) {
201- self . key = key
202- self . value = value
203- }
204-
205- var body : some View {
206- HStack {
207- Text ( key ) . font ( . sligoilMicroBold ( . subheadline ) )
208- Spacer ( )
209- Text ( value ) . font ( . sligoilMicro ( . subheadline ) )
210- }
211- . foregroundStyle ( . themePrimaryInverted )
212- . opacity ( 0.625 )
213- }
214- }
215-
216198private struct AlbumTrackSection : View {
217199 let tracks : [ AlbumTrack ]
218200
219201 var body : some View {
220- VStack ( alignment : . leading , spacing : Padding . xl ) {
221- SectionHeader ( " Tracks " )
222- Section {
223- if tracks . isEmpty {
202+ ThemeSection {
203+ if tracks . isEmpty {
204+ Section ( " Tracks " ) {
224205 ProgressView ( )
225- } else {
226- VStack ( spacing : Spacing . sm ) {
227- ForEach ( tracks . enumerated ( ) , id : \. offset ) { i , track in
228- AlbumTrackRow ( track )
229- if i < tracks . count - 1 {
230- Divider ( )
231- }
232- }
206+ }
207+ } else {
208+ Section {
209+ ForEach ( tracks ) { track in
210+ AlbumTrackRow ( track : track )
211+ }
212+ } header : {
213+ Text ( " Tracks " )
214+ } footer : {
215+ let anyPreview = tracks . contains { $0 . previewUrl != nil }
216+ if anyPreview {
217+ Text ( " Tracks provided courtesy of iTunes. " )
233218 }
234219 }
235220 }
@@ -242,10 +227,6 @@ private struct AlbumTrackRow: View {
242227
243228 let track : AlbumTrack
244229
245- init ( _ track : AlbumTrack ) {
246- self . track = track
247- }
248-
249230 var body : some View {
250231 let isPlaying = track . title == player . preview ? . title
251232
@@ -257,41 +238,28 @@ private struct AlbumTrackRow: View {
257238 : await player . play ( url , title : track . title )
258239 }
259240 } label : {
260- HStack {
261- Group {
262- if track . previewUrl == nil {
263- Image ( systemName : " play.slash " )
264- } else {
265- PlaybackIndicator ( isPlaying : isPlaying , progress : player . progress )
241+ LabeledContent {
242+ Text ( track . duration ?? " N/A " )
243+ } label : {
244+ HStack ( spacing : Spacing . sm ) {
245+ Group {
246+ if track . previewUrl == nil {
247+ Icon ( systemName : " play.slash " )
248+ } else {
249+ PlaybackIndicator ( isPlaying : isPlaying , progress : player . progress )
250+ }
266251 }
267- }
268- . frame ( width : 24 )
269-
270- Text ( track . title )
271- . font ( . sligoilMicroBold ( . subheadline ) )
272- . minimumScaleFactor ( 0.75 )
273- . lineLimit ( 1 )
274-
275- Spacer ( )
252+ . frame ( width : 24 )
276253
277- Text ( track . duration ?? " N/A " )
278- . font ( . sligoilMicro ( . subheadline ) )
254+ Text ( track . title )
255+ . lineLimit ( 1 )
256+ }
279257 }
280- . contentShape ( . rect )
281258 }
282259 . buttonStyle ( . plain )
283- . allowsHitTesting ( track . previewUrl != nil )
284- // .disabled(track.previewUrl == nil)
285- . foregroundStyle (
286- isPlaying
287- ? . accent
288- : . themePrimaryInverted
289- )
290- . animation (
291- . easeInOut ( duration : 0.25 ) ,
292- value : isPlaying ,
293- )
294- . opacity ( 0.625 )
260+ . labeledContentStyle ( . withThemeFont ( isActive : isPlaying ) )
261+ . animation ( . easeInOut , value : isPlaying )
262+ . disabled ( track . previewUrl == nil )
295263 }
296264}
297265
0 commit comments