From 9b04a162c7c774b5794d05c2bfd1f855dad2d495 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 23 Feb 2022 09:51:45 -0800 Subject: [PATCH] load profile view model from home view model --- .../Sources/Binders/Scenes/HomeFeedScene.swift | 4 ++++ .../Views/PrimaryContainerViews/HomeFeedView.swift | 7 +++++-- .../Profile/ProfileContainerView.swift | 12 ++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift b/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift index 820cbf624..5f4541645 100644 --- a/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift +++ b/apple/OmnivoreKit/Sources/Binders/Scenes/HomeFeedScene.swift @@ -11,6 +11,10 @@ extension HomeFeedViewModel { LinkItemDetailViewModel.make(feedItem: feedItem, services: services) } + if UIDevice.isIPhone { + viewModel.profileContainerViewModel = ProfileContainerViewModel.make(services: services) + } + viewModel.bind(services: services) viewModel.loadItems(dataService: services.dataService, searchQuery: nil, isRefresh: false) return viewModel diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift index 0fb5d0dde..d3360d2b1 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift +++ b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/HomeFeedView.swift @@ -6,6 +6,7 @@ import Utils public final class HomeFeedViewModel: ObservableObject { let detailViewModelCreator: (FeedItem) -> LinkItemDetailViewModel var currentDetailViewModel: LinkItemDetailViewModel? + public var profileContainerViewModel: ProfileContainerViewModel? @Published public var items = [FeedItem]() @Published public var isLoading = false @@ -256,13 +257,15 @@ public struct HomeFeedView: View { public var body: some View { #if os(iOS) - if UIDevice.isIPhone { + if UIDevice.isIPhone, let profileContainerViewModel = viewModel.profileContainerViewModel { NavigationView { conditionalInnerBody .toolbar { ToolbarItem { NavigationLink( - destination: { EmptyView() }, + destination: { + ProfileContainerView(viewModel: profileContainerViewModel) + }, label: { Image.profileTab.padding() } ) } diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/Profile/ProfileContainerView.swift b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/Profile/ProfileContainerView.swift index 9ac0769d7..3c3a9fc16 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/Profile/ProfileContainerView.swift +++ b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/Profile/ProfileContainerView.swift @@ -30,16 +30,8 @@ public struct ProfileContainerView: View { public var body: some View { #if os(iOS) - if UIDevice.isIPhone { - NavigationView { - Form { - innerBody - } - } - } else { - Form { - innerBody - } + Form { + innerBody } #elseif os(macOS) List {