Merge pull request #202 from omnivore-app/feature/ipad-pull-to-refresh

iPad pull to refresh
This commit is contained in:
Satindar Dhillon 2022-03-07 21:12:40 -08:00 committed by GitHub
commit 4954aee4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 6 deletions

View file

@ -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)
}

View file

@ -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()
}
}

View file

@ -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)

View file

@ -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

View file

@ -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
}