mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #202 from omnivore-app/feature/ipad-pull-to-refresh
iPad pull to refresh
This commit is contained in:
commit
4954aee4ad
5 changed files with 49 additions and 6 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue