blob: 278a81403bb12c18e9766b3ad822fb13d2b3a082 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import SwiftUI
struct PostDetailsCarouselItemView: View {
var post: BooruPost
var index: Int
@Binding var loadingStage: BooruPostLoadingState
var imageURL: (BooruPost) -> URL?
private var systemBackgroundColor: Color {
#if os(iOS)
return Color(.systemBackground)
#elseif os(macOS)
return Color(.windowBackgroundColor)
#else
return Color.gray
#endif
}
var body: some View {
ZStack {
PostDetailsImageView(
url: post.previewURL,
loadingStage: $loadingStage
) {
GeometryReader { geometry in
ProgressView()
.frame(width: geometry.size.width, height: geometry.size.height)
}
}
PostDetailsImageView(
url: imageURL(post),
loadingStage: $loadingStage,
finalLoadingState: .loaded,
post: post
)
.background(
loadingStage == .loaded ? systemBackgroundColor : Color.clear
)
}
.tag(index)
}
}
|