summaryrefslogtreecommitdiff
path: root/Sora/Views/Post/Details
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-06-28 06:29:58 -0700
committerFuwn <[email protected]>2025-06-28 06:29:58 -0700
commit2a47b7f0ff2e61b12b415fe987c854c1d0abad99 (patch)
treefb206a648a9d12e4911f399d6f9214c90cea56d5 /Sora/Views/Post/Details
parentfeat: Development commit (diff)
downloadsora-testing-2a47b7f0ff2e61b12b415fe987c854c1d0abad99.tar.xz
sora-testing-2a47b7f0ff2e61b12b415fe987c854c1d0abad99.zip
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Details')
-rw-r--r--Sora/Views/Post/Details/Carousel/PostDetailsCarouselView.swift28
1 files changed, 19 insertions, 9 deletions
diff --git a/Sora/Views/Post/Details/Carousel/PostDetailsCarouselView.swift b/Sora/Views/Post/Details/Carousel/PostDetailsCarouselView.swift
index 52377b2..e8ab57a 100644
--- a/Sora/Views/Post/Details/Carousel/PostDetailsCarouselView.swift
+++ b/Sora/Views/Post/Details/Carousel/PostDetailsCarouselView.swift
@@ -6,7 +6,7 @@ struct PostDetailsCarouselView: View {
let posts: [BooruPost]
let focusedPost: BooruPost?
@Binding var loadingStage: BooruPostLoadingState
- @State private var currentIndex: Int
+ @State private var currentIndex: Int?
private let cacheManager = ImageCacheManager.shared
init(
@@ -41,17 +41,26 @@ struct PostDetailsCarouselView: View {
}
var body: some View {
- TabView(selection: $currentIndex) {
- ForEach(Array(posts.enumerated()), id: \.offset) { index, post in
- PostDetailsCarouselItemView(
- post: post,
- index: index,
- loadingStage: $loadingStage,
- imageURL: imageURL
- )
+ ScrollView(.horizontal) {
+ LazyHStack(spacing: 0) {
+ ForEach(Array(posts.enumerated()), id: \.offset) { index, post in
+ PostDetailsCarouselItemView(
+ post: post,
+ index: index,
+ loadingStage: $loadingStage,
+ imageURL: imageURL
+ )
+ .frame(width: UIScreen.main.bounds.width)
+ }
}
+ .scrollTargetLayout()
}
+ .scrollPosition(id: $currentIndex)
+ .scrollIndicators(.hidden)
+ .scrollTargetBehavior(.paging)
.onChange(of: currentIndex) {
+ guard let currentIndex else { return }
+
Task(priority: .utility) {
if currentIndex == posts.count - 1 { await manager.loadNextPage() }
}
@@ -70,6 +79,7 @@ struct PostDetailsCarouselView: View {
let preloadRange = settings.preloadedCarouselImages
guard preloadRange > 0 else { return }
+ guard let currentIndex else { return }
let startIndex = max(0, currentIndex - preloadRange)
let endIndex = min(posts.count - 1, currentIndex + preloadRange)