@@ -9,46 +9,27 @@ struct AlbumHistoryCard: View {
99 . roundedOutline ( lineWidth : LineWidth . sm )
1010
1111 HStack ( alignment : . center ) {
12- AlbumHeader ( title : album . title , artist : album . artist )
12+ LabeledContent ( album . artist , value : album . title )
1313 . frame ( maxWidth : . infinity , alignment : . leading )
14- // .minimumScaleFactor(0.75)
14+ . labeledContentStyle ( . albumHeader )
15+ . controlSize ( . small )
1516 . lineLimit ( 1 )
1617
1718 Spacer ( )
1819
19- Icon ( systemName : " star .fill" )
20+ Image ( systemName : " heart .fill" )
2021 . favoriteIconStyle ( isFavorite : album . isFavorite )
22+ . opacity ( album . isFavorite ? 1 : 0 )
2123
22- Text ( ( album . selectedAt . shortRelative ( to : . now ) ) )
24+ Text ( album . selectedAt . shortRelative ( to : . now ) )
2325 . badgeStyle ( )
2426 . controlSize ( . mini )
2527 }
26- . frame ( height : 40 )
28+ . padding ( . vertical , Padding . sm )
2729 }
2830 }
2931}
3032
31- struct FavoriteIconStyle : ViewModifier {
32- let isFavorite : Bool
33-
34- func body ( content : Content ) -> some View {
35- content
36- . foregroundStyle ( . accent )
37- . symbolEffect (
38- . bounce . up ,
39- options : . speed ( 2 ) ,
40- value : isFavorite ,
41- )
42- . opacity ( isFavorite ? 1 : 0 )
43- }
44- }
45-
46- extension View {
47- func favoriteIconStyle ( isFavorite : Bool ) -> some View {
48- modifier ( FavoriteIconStyle ( isFavorite : isFavorite ) )
49- }
50- }
51-
5233private struct AlbumCover : View {
5334 let url : URL ?
5435
@@ -71,38 +52,57 @@ private struct AlbumCover: View {
7152import SwiftData
7253
7354private struct TestHistoryCard : View {
74- let album1 : Album
75- let album2 : Album
55+ let album : Album
7656
7757 var body : some View {
78- HStack {
79- Button {
80- album1 . isFavorite . toggle ( )
81- } label : {
82- AlbumHistoryCard ( album : album1 )
83- . contentShape ( . rect )
84- }
58+ Button {
59+ album . isFavorite . toggle ( )
60+ } label : {
61+ AlbumHistoryCard ( album : album )
62+ . contentShape ( . rect )
63+ }
64+ }
65+ }
8566
86- Spacer ( )
67+ #Preview ( " Single Column " , traits : . withSampleData ) {
68+ @Previewable @Query ( sort : \Album . selectedAt ) var albums : [ Album ]
8769
88- Button {
89- album2 . isFavorite . toggle ( )
90- } label : {
91- AlbumHistoryCard ( album : album2 )
92- . contentShape ( . rect )
70+ if albums . isEmpty {
71+ ProgressView ( )
72+ } else {
73+ ScrollView {
74+ WithColorSchemes {
75+ LazyVGrid ( columns : [ . init ( . flexible ( ) ) ] ) {
76+ TestHistoryCard ( album : albums [ 0 ] )
77+ }
78+ . padding ( )
9379 }
9480 }
95- . buttonStyle ( . plain )
9681 }
9782}
9883
99- #Preview ( traits : . withSampleData ) {
84+ #Preview ( " Double Column " , traits : . withSampleData ) {
85+ @Previewable @Environment ( \. dynamicTypeSize ) var dynamicTypeSize
86+
10087 @Previewable @Query ( sort : \Album . selectedAt ) var albums : [ Album ]
10188
89+ var columns : [ GridItem ] {
90+ [
91+ dynamicTypeSize . isAccessibilitySize
92+ ? GridItem ( . flexible ( minimum : 160 ) )
93+ : GridItem ( . adaptive ( minimum : 160 ) )
94+ ]
95+ }
96+
10297 if albums . count > 1 {
103- WithColorSchemes {
104- TestHistoryCard ( album1 : albums [ 0 ] , album2 : albums [ 1 ] )
98+ ScrollView {
99+ WithColorSchemes {
100+ LazyVGrid ( columns : columns ) {
101+ TestHistoryCard ( album : albums [ 0 ] )
102+ TestHistoryCard ( album : albums [ 1 ] )
103+ }
105104 . padding ( )
105+ }
106106 }
107107 } else {
108108 ProgressView ( )
0 commit comments