From 2040f8efe2c8a23e9e972fb831ca21b76d74a2cb Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 28 Feb 2022 10:21:44 -0800 Subject: [PATCH] move home feed components into separate files --- .../Components/FeedCardNavigationLink.swift | 30 ++++++++++++++ .../FeedItemContextMenuView.swift} | 39 ------------------- .../Sources/Views/LoadingSection.swift | 16 ++++++++ 3 files changed, 46 insertions(+), 39 deletions(-) create mode 100644 apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift rename apple/OmnivoreKit/Sources/App/Views/Home/{HomeFeedViewComponents.swift => Components/FeedItemContextMenuView.swift} (58%) create mode 100644 apple/OmnivoreKit/Sources/Views/LoadingSection.swift diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift new file mode 100644 index 000000000..7fd196068 --- /dev/null +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedCardNavigationLink.swift @@ -0,0 +1,30 @@ +import Models +import Services +import SwiftUI +import Views + +struct FeedCardNavigationLink: View { + @EnvironmentObject var dataService: DataService + + let item: FeedItem + let searchQuery: String + + @Binding var selectedLinkItem: FeedItem? + + @ObservedObject var viewModel: HomeFeedViewModel + var body: some View { + NavigationLink( + destination: LinkItemDetailView(viewModel: LinkItemDetailViewModel(item: item)), + tag: item, + selection: $selectedLinkItem + ) { + EmptyView() + } + .opacity(0) + .buttonStyle(PlainButtonStyle()) + .onAppear { + viewModel.itemAppeared(item: item, searchQuery: searchQuery, dataService: dataService) + } + FeedCard(item: item) + } +} diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewComponents.swift b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedItemContextMenuView.swift similarity index 58% rename from apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewComponents.swift rename to apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedItemContextMenuView.swift index 62b756050..6441e5454 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewComponents.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/Components/FeedItemContextMenuView.swift @@ -42,42 +42,3 @@ struct FeedItemContextMenuView: View { } } } - -struct FeedCardNavigationLink: View { - @EnvironmentObject var dataService: DataService - - let item: FeedItem - let searchQuery: String - - @Binding var selectedLinkItem: FeedItem? - - @ObservedObject var viewModel: HomeFeedViewModel - var body: some View { - NavigationLink( - destination: LinkItemDetailView(viewModel: LinkItemDetailViewModel(item: item)), - tag: item, - selection: $selectedLinkItem - ) { - EmptyView() - } - .opacity(0) - .buttonStyle(PlainButtonStyle()) - .onAppear { - viewModel.itemAppeared(item: item, searchQuery: searchQuery, dataService: dataService) - } - FeedCard(item: item) - } -} - -struct LoadingSection: View { - var body: some View { - Section { - HStack(alignment: .center) { - Spacer() - Text("Loading...") - Spacer() - } - .frame(maxWidth: .infinity) - } - } -} diff --git a/apple/OmnivoreKit/Sources/Views/LoadingSection.swift b/apple/OmnivoreKit/Sources/Views/LoadingSection.swift new file mode 100644 index 000000000..ab534ad54 --- /dev/null +++ b/apple/OmnivoreKit/Sources/Views/LoadingSection.swift @@ -0,0 +1,16 @@ +import SwiftUI + +public struct LoadingSection: View { + public init() {} + + public var body: some View { + Section { + HStack(alignment: .center) { + Spacer() + Text("Loading...") + Spacer() + } + .frame(maxWidth: .infinity) + } + } +}