summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-03-02 17:18:14 -0800
committerFuwn <[email protected]>2025-03-02 17:18:14 -0800
commit40fb6c23224c2d9aad265e8f671817028725dcf6 (patch)
treeddf0f1a6c96b666554c7bbe0fe20e94f820b0a84 /Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift
parentfeat: Development commit (diff)
downloadsora-testing-40fb6c23224c2d9aad265e8f671817028725dcf6.tar.xz
sora-testing-40fb6c23224c2d9aad265e8f671817028725dcf6.zip
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift')
-rw-r--r--Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift37
1 files changed, 37 insertions, 0 deletions
diff --git a/Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift b/Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift
new file mode 100644
index 0000000..c4aa292
--- /dev/null
+++ b/Sora/Views/Post/Details/Carousel/PostDetailsCarouselItemView.swift
@@ -0,0 +1,37 @@
+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
+ )
+
+ PostDetailsImageView(
+ url: imageURL(post),
+ loadingStage: $loadingStage,
+ finalLoadingState: .loaded,
+ post: post
+ )
+ .background(
+ loadingStage == .loaded ? systemBackgroundColor : Color.clear
+ )
+ }
+ .tag(index)
+ }
+}