diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift index 093310ca1..3d60094ff 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift @@ -53,9 +53,6 @@ struct GridCardNavigationLink: View { ) { EmptyView() } - .onAppear { - viewModel.itemAppeared(item: item, searchQuery: searchQuery, dataService: dataService) - } GridCard(item: item, isContextMenuOpen: $isContextMenuOpen, actionHandler: actionHandler, tapAction: { withAnimation { scale = 0.95 @@ -65,6 +62,9 @@ struct GridCardNavigationLink: View { } } }) + .onAppear { + viewModel.itemAppeared(item: item, searchQuery: searchQuery, dataService: dataService) + } } .scaleEffect(scale) } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index f4a82b029..cacd54ce8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -301,7 +301,7 @@ import Views var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: 20) { - ForEach(viewModel.items) { item in + ForEach(viewModel.items, id: \.renderID) { item in let link = GridCardNavigationLink( item: item, searchQuery: searchQuery, @@ -329,9 +329,21 @@ import Views } } .padding() - .background(Color(.systemGroupedBackground)) + .background( + GeometryReader { + Color(.systemGroupedBackground).preference( + key: ScrollViewOffsetPreferenceKey.self, + value: $0.frame(in: .global).origin.y + ) + } + ) + .onPreferenceChange(ScrollViewOffsetPreferenceKey.self) { offset in + if !viewModel.isLoading, offset > 240 { + viewModel.loadItems(dataService: dataService, searchQuery: searchQuery, isRefresh: true) + } + } - if viewModel.isLoading { + if viewModel.items.isEmpty, viewModel.isLoading { LoadingSection() } } @@ -339,3 +351,11 @@ import Views } #endif + +struct ScrollViewOffsetPreferenceKey: PreferenceKey { + typealias Value = CGFloat + static var defaultValue = CGFloat.zero + static func reduce(value: inout Value, nextValue: () -> Value) { + value += nextValue() + } +} diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index 04f1e7e1c..d6f276e69 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -169,6 +169,27 @@ struct LinkItemDetailView: View { ) .padding(.horizontal) .scaleEffect(navBarVisibilityRatio) + if FeatureFlag.showLinkOptionsOnReaderView { + Menu( + content: { + Group { + Button( + action: {}, + label: { Label("Archive", systemImage: "archivebox") } + ) + Button( + action: {}, + label: { Label("Delete Link", systemImage: "trash") } + ) + } + }, + label: { + Image.profile + .padding(.horizontal) + .scaleEffect(navBarVisibilityRatio) + } + ) + } } .frame(height: readerViewNavBarHeight * navBarVisibilityRatio) .opacity(navBarVisibilityRatio) diff --git a/apple/OmnivoreKit/Sources/Models/FeedItem.swift b/apple/OmnivoreKit/Sources/Models/FeedItem.swift index 4b4010ab5..b61022b01 100644 --- a/apple/OmnivoreKit/Sources/Models/FeedItem.swift +++ b/apple/OmnivoreKit/Sources/Models/FeedItem.swift @@ -12,6 +12,7 @@ public struct HomeFeedData { public struct FeedItem: Identifiable, Hashable, Decodable { public let id: String + public let renderID = UUID() public let title: String public var readingProgress: Double public var readingProgressAnchor: Int diff --git a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift index 67a1faf37..a5a911bd4 100644 --- a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift +++ b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift @@ -15,4 +15,5 @@ public enum FeatureFlag { public static let enableShareButton = false public static let enableSnooze = false public static let showFeedItemTags = false + public static let showLinkOptionsOnReaderView = false }