@@ -56,21 +56,31 @@ struct CafeSearchListCell: View {
56
56
ScrollView ( . horizontal, showsIndicators: false ) {
57
57
HStack ( spacing: 8 ) {
58
58
if let imageUrls = cafe. imageUrls, imageUrls. isNotEmpty {
59
- ForEach ( imageUrls, id: \. self) { imageUrl in
60
- KFImage . url ( URL ( string: imageUrl) )
61
- . placeholder { CofficeAsset . Asset. cafePlaceholder. swiftUIImage }
62
- . resizable ( )
59
+ ForEach ( imageUrls, id: \. self) { imageUrlString in
60
+ if let imageUrl = URL ( string: imageUrlString) {
61
+ LinearGradient (
62
+ gradient: Gradient ( colors: [ . black. opacity ( 0.06 ) , . black. opacity ( 0.3 ) ] ) ,
63
+ startPoint: . top,
64
+ endPoint: . bottom
65
+ )
66
+ . background (
67
+ alignment: . center,
68
+ content: {
69
+ KFImage . url ( imageUrl)
70
+ . resizable ( )
71
+ . scaledToFill ( )
72
+ }
73
+ )
63
74
. frame ( width: 124 , height: 112 )
64
- . scaledToFit ( )
75
+ . clipped ( )
65
76
. cornerRadius ( 4 , corners: . allCorners)
77
+ } else {
78
+ placeholderImage
79
+ }
66
80
}
67
81
} else {
68
82
ForEach ( 1 ... 3 , id: \. self) { imageAsset in
69
- CofficeAsset . Asset. cafePlaceholder. swiftUIImage
70
- . resizable ( )
71
- . frame ( width: 124 , height: 112 )
72
- . scaledToFit ( )
73
- . cornerRadius ( 4 , corners: . allCorners)
83
+ placeholderImage
74
84
}
75
85
}
76
86
}
@@ -84,6 +94,20 @@ struct CafeSearchListCell: View {
84
94
}
85
95
}
86
96
}
97
+
98
+ var placeholderImage : some View {
99
+ CofficeAsset . Colors. grayScale2. swiftUIColor
100
+ . frame ( width: 124 , height: 112 )
101
+ . cornerRadius ( 4 , corners: . allCorners)
102
+ . overlay (
103
+ alignment: . center,
104
+ content: {
105
+ CofficeAsset . Asset. icPlaceholder. swiftUIImage
106
+ . resizable ( )
107
+ . frame ( width: 44 , height: 44 )
108
+ }
109
+ )
110
+ }
87
111
}
88
112
89
113
struct CafeSearchListCell_Previews : PreviewProvider {
0 commit comments