load profile view model from home view model

This commit is contained in:
Satindar Dhillon
2022-02-23 09:51:45 -08:00
parent 762747be95
commit 9b04a162c7
3 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -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() }
)
}

View File

@ -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 {