diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 04a07ba01..bf44c0e8d 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -289,7 +289,8 @@ import Views @ObservedObject var viewModel: HomeFeedViewModel - private let columns = Array(repeating: GridItem(.flexible(), spacing: 20), count: 2) + private let twoColumns = Array(repeating: GridItem(.flexible(), spacing: 20), count: 2) + private let oneColumn = [GridItem(.flexible(), spacing: 20)] func contextMenuActionHandler(item: FeedItem, action: GridCardAction) { switch action { @@ -303,51 +304,53 @@ import Views var body: some View { ScrollView { - LazyVGrid(columns: columns, spacing: 20) { - ForEach(viewModel.items, id: \.renderID) { item in - let link = GridCardNavigationLink( - item: item, - searchQuery: searchQuery, - actionHandler: { contextMenuActionHandler(item: item, action: $0) }, - selectedLinkItem: $selectedLinkItem, - isContextMenuOpen: $isContextMenuOpen, - viewModel: viewModel - ) - if #available(iOS 15.0, *) { - link - .alert("Are you sure?", isPresented: $confirmationShown) { - Button("Remove Link", role: .destructive) { - if let itemToRemove = itemToRemove { - withAnimation { - viewModel.removeLink(dataService: dataService, linkId: itemToRemove.id) + GeometryReader { geo in + LazyVGrid(columns: geo.size.width < 500 ? oneColumn : twoColumns, spacing: 20) { + ForEach(viewModel.items, id: \.renderID) { item in + let link = GridCardNavigationLink( + item: item, + searchQuery: searchQuery, + actionHandler: { contextMenuActionHandler(item: item, action: $0) }, + selectedLinkItem: $selectedLinkItem, + isContextMenuOpen: $isContextMenuOpen, + viewModel: viewModel + ) + if #available(iOS 15.0, *) { + link + .alert("Are you sure?", isPresented: $confirmationShown) { + Button("Remove Link", role: .destructive) { + if let itemToRemove = itemToRemove { + withAnimation { + viewModel.removeLink(dataService: dataService, linkId: itemToRemove.id) + } } + self.itemToRemove = nil } - self.itemToRemove = nil + Button("Cancel", role: .cancel) { self.itemToRemove = nil } } - Button("Cancel", role: .cancel) { self.itemToRemove = nil } - } - } else { - link + } else { + link + } } } - } - .padding() - .background( - GeometryReader { - Color(.systemGroupedBackground).preference( - key: ScrollViewOffsetPreferenceKey.self, - value: $0.frame(in: .global).origin.y - ) + .padding() + .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) + } } - ) - .onPreferenceChange(ScrollViewOffsetPreferenceKey.self) { offset in - if !viewModel.isLoading, offset > 240 { - viewModel.loadItems(dataService: dataService, searchQuery: searchQuery, isRefresh: true) - } - } - if viewModel.items.isEmpty, viewModel.isLoading { - LoadingSection() + if viewModel.items.isEmpty, viewModel.isLoading { + LoadingSection() + } } } .onAppear { diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift index 62181c412..2be7ba9a5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeView.swift @@ -24,8 +24,8 @@ struct HomeView: View { } .accentColor(.appGrayTextContrast) } else { - GeometryReader { geo in - HomeFeedContainerView(isCompact: geo.size.width < 500, viewModel: viewModel) + GeometryReader { _ in + HomeFeedContainerView(isCompact: UIDevice.isIPhone, viewModel: viewModel) } } #elseif os(macOS) diff --git a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift index 1320cfc07..1bea072f8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift @@ -43,12 +43,17 @@ public struct PrimaryContentView: View { NavigationView { // The first column is the sidebar. PrimaryContentSidebar(categories: categories) - .navigationTitle("Categories") + .navigationTitle("") + .navigationBarTitleDisplayMode(.inline) // Second column is the Primary Nav Stack PrimaryContentCategory.feed.destinationView } .accentColor(.appGrayTextContrast) + .introspectSplitViewController { + $0.preferredSplitBehavior = .tile + $0.preferredPrimaryColumnWidth = 200 + } } #endif }