diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 27cd7e70c..24b1c6b61 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -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 diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 6cc43df1c..9f89b307b 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -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] {