From cd340066353e75e837874f1167bbcd91b38c1ac3 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 24 Feb 2025 23:34:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E7=B3=BB=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dimensionhub/Views/IndexView.swift | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dimensionhub/Views/IndexView.swift b/dimensionhub/Views/IndexView.swift index 98c1181..e0eff50 100644 --- a/dimensionhub/Views/IndexView.swift +++ b/dimensionhub/Views/IndexView.swift @@ -264,10 +264,12 @@ struct IndexView: View { .background(GeometryReader { geometry in Color.clear.onChange(of: geometry.frame(in: .global).minY) {_, offset in + let frame = geometry.frame(in: .global) let screenBounds = UIScreen.main.bounds - - if screenBounds.height - frame.minY > 50 && !isMoreLoading { + let contextFrame = geometry.frame(in: .named("scrollView")) + + if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading { Task { self.isMoreLoading = true await self.indexModel.loadMoreUpdateDramas(userId: 1, mode: .next) @@ -281,6 +283,7 @@ struct IndexView: View { ProgressView() } } + .coordinateSpace(name: "scrollView") .popover(isPresented: $showDateNavPopover) { DateNavView(selectGroupId: self.$selectGroupId, showDateNavPopover: $showDateNavPopover) { selectedDate in print("new selected date: " + selectedDate) @@ -328,15 +331,6 @@ struct IndexView: View { extension IndexView { - // 自定义 PreferenceKey 用于获取滚动偏移量 - struct ScrollOffsetKey: PreferenceKey { - static var defaultValue: CGFloat = 0 - - static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { - value = nextValue() - } - } - // 显示剧集的列表信息 struct DramaCellView: View { let dramaItem: IndexModel.DramaItem