mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Simpler loading view when loading from the refresh button
This commit is contained in:
parent
c6517ebb8e
commit
67bc196496
2 changed files with 29 additions and 7 deletions
|
|
@ -91,7 +91,7 @@ struct EmptyState: View {
|
|||
Text("You are all caught up.").foregroundColor(Color.extensionTextSubtle)
|
||||
Button(action: {
|
||||
Task {
|
||||
await viewModel.loadItems(dataService: dataService, isRefresh: true)
|
||||
await viewModel.loadItems(dataService: dataService, isRefresh: true, loadingBarStyle: .simple)
|
||||
}
|
||||
}, label: { Text("Refresh").bold() })
|
||||
.foregroundColor(Color.blue)
|
||||
|
|
@ -790,8 +790,16 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||
}
|
||||
}
|
||||
|
||||
if viewModel.showLoadingBar {
|
||||
if viewModel.showLoadingBar == .redacted {
|
||||
redactedItems
|
||||
} else if viewModel.showLoadingBar == .simple {
|
||||
VStack {
|
||||
ProgressView()
|
||||
}
|
||||
.frame(minHeight: 400)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding()
|
||||
.listRowSeparator(.hidden, edges: .all)
|
||||
} else if viewModel.fetcher.items.isEmpty {
|
||||
EmptyState(viewModel: viewModel)
|
||||
.listRowSeparator(.hidden, edges: .all)
|
||||
|
|
@ -951,13 +959,21 @@ struct AnimatingCellHeight: AnimatableModifier {
|
|||
|
||||
ScrollView {
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 325, maximum: 400), spacing: 16)], alignment: .center, spacing: 30) {
|
||||
if viewModel.showLoadingBar {
|
||||
if viewModel.showLoadingBar == .redacted {
|
||||
ForEach(fakeLibraryItems(dataService: dataService), id: \.id) { item in
|
||||
GridCard(item: item)
|
||||
.aspectRatio(1.0, contentMode: .fill)
|
||||
.background(Color.systemBackground)
|
||||
.cornerRadius(6)
|
||||
}.redacted(reason: .placeholder)
|
||||
} else if viewModel.showLoadingBar == .simple {
|
||||
VStack {
|
||||
ProgressView()
|
||||
}
|
||||
.frame(minHeight: 400)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding()
|
||||
.listRowSeparator(.hidden, edges: .all)
|
||||
} else {
|
||||
if !viewModel.fetcher.items.isEmpty {
|
||||
ForEach(Array(viewModel.fetcher.items.enumerated()), id: \.1.id) { idx, item in
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ import SwiftUI
|
|||
import Utils
|
||||
import Views
|
||||
|
||||
enum LoadingBarStyle {
|
||||
case none
|
||||
case redacted
|
||||
case simple
|
||||
}
|
||||
|
||||
@MainActor final class HomeFeedViewModel: NSObject, ObservableObject {
|
||||
let filterKey: String
|
||||
@ObservedObject var fetcher: LibraryItemFetcher
|
||||
|
|
@ -16,7 +22,7 @@ import Views
|
|||
@Published var itemForHighlightsView: Models.LibraryItem?
|
||||
@Published var linkRequest: LinkRequest?
|
||||
@Published var presentWebContainer = false
|
||||
@Published var showLoadingBar = true
|
||||
@Published var showLoadingBar = LoadingBarStyle.redacted
|
||||
|
||||
@Published var selectedItem: Models.LibraryItem?
|
||||
@Published var linkIsActive = false
|
||||
|
|
@ -194,9 +200,9 @@ import Views
|
|||
}
|
||||
}
|
||||
|
||||
func loadItems(dataService: DataService, isRefresh: Bool, forceRemote: Bool = false) async {
|
||||
func loadItems(dataService: DataService, isRefresh: Bool, forceRemote: Bool = false, loadingBarStyle: LoadingBarStyle? = nil) async {
|
||||
isLoading = true
|
||||
showLoadingBar = isRefresh
|
||||
showLoadingBar = isRefresh ? loadingBarStyle ?? .redacted : .none
|
||||
|
||||
if let filterState = filterState {
|
||||
await fetcher.loadItems(
|
||||
|
|
@ -208,7 +214,7 @@ import Views
|
|||
}
|
||||
|
||||
isLoading = false
|
||||
showLoadingBar = false
|
||||
showLoadingBar = .none
|
||||
}
|
||||
|
||||
func loadFeatureItems(context: NSManagedObjectContext, predicate: NSPredicate, sort: NSSortDescriptor) async -> [Models.LibraryItem] {
|
||||
|
|
|
|||
Loading…
Reference in a new issue