diff --git a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift index 0afd577ad..18f7fcb3f 100644 --- a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift +++ b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift @@ -127,7 +127,7 @@ public struct RootView: View { let rootViewModel = RootViewModel() self.viewModel = rootViewModel self.authenticator = rootViewModel.services.authenticator - self.primaryViewModel = PrimaryContentViewModel.make(services: rootViewModel.services) + self.primaryViewModel = PrimaryContentViewModel(services: rootViewModel.services) #if DEBUG if CommandLine.arguments.contains("--uitesting") { diff --git a/apple/OmnivoreKit/Sources/Binders/Scenes/PrimaryContentScene.swift b/apple/OmnivoreKit/Sources/Binders/Scenes/PrimaryContentScene.swift deleted file mode 100644 index 1dfe9b3fb..000000000 --- a/apple/OmnivoreKit/Sources/Binders/Scenes/PrimaryContentScene.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Services -import SwiftUI -import Views - -extension PrimaryContentViewModel { - static func make(services: Services) -> PrimaryContentViewModel { - PrimaryContentViewModel( - homeFeedViewModel: HomeFeedViewModel.make(services: services), - profileContainerViewModel: ProfileContainerViewModel.make(services: services) - ) - } -} diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentView.swift b/apple/OmnivoreKit/Sources/Binders/Views/PrimaryContentView.swift similarity index 85% rename from apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentView.swift rename to apple/OmnivoreKit/Sources/Binders/Views/PrimaryContentView.swift index 5be1f3e29..103f6f355 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentView.swift +++ b/apple/OmnivoreKit/Sources/Binders/Views/PrimaryContentView.swift @@ -1,22 +1,20 @@ -import Combine import Models +import Services import SwiftUI +import Views -public final class PrimaryContentViewModel: ObservableObject { +public final class PrimaryContentViewModel { let homeFeedViewModel: HomeFeedViewModel let profileContainerViewModel: ProfileContainerViewModel - public init( - homeFeedViewModel: HomeFeedViewModel, - profileContainerViewModel: ProfileContainerViewModel - ) { - self.homeFeedViewModel = homeFeedViewModel - self.profileContainerViewModel = profileContainerViewModel + public init(services: Services) { + self.homeFeedViewModel = HomeFeedViewModel.make(services: services) + self.profileContainerViewModel = ProfileContainerViewModel.make(services: services) } } public struct PrimaryContentView: View { - @ObservedObject private var viewModel: PrimaryContentViewModel + private let viewModel: PrimaryContentViewModel public init(viewModel: PrimaryContentViewModel) { self.viewModel = viewModel diff --git a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentCategory.swift b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentCategory.swift index 822cea342..13919d14e 100644 --- a/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentCategory.swift +++ b/apple/OmnivoreKit/Sources/Views/PrimaryContainerViews/PrimaryContentCategory.swift @@ -1,14 +1,14 @@ import SwiftUI -enum PrimaryContentCategory: Identifiable, Hashable, Equatable { +public enum PrimaryContentCategory: Identifiable, Hashable, Equatable { case feed(viewModel: HomeFeedViewModel) case profile(viewModel: ProfileContainerViewModel) - static func == (lhs: PrimaryContentCategory, rhs: PrimaryContentCategory) -> Bool { + public static func == (lhs: PrimaryContentCategory, rhs: PrimaryContentCategory) -> Bool { lhs.id == rhs.id } - var id: String { + public var id: String { title } @@ -39,11 +39,11 @@ enum PrimaryContentCategory: Identifiable, Hashable, Equatable { } } - var listLabel: some View { + public var listLabel: some View { Label { Text(title) } icon: { image.renderingMode(.template) } } - @ViewBuilder var destinationView: some View { + @ViewBuilder public var destinationView: some View { switch self { case let .feed(viewModel: viewModel): HomeFeedView(viewModel: viewModel) @@ -52,7 +52,7 @@ enum PrimaryContentCategory: Identifiable, Hashable, Equatable { } } - func hash(into hasher: inout Hasher) { + public func hash(into hasher: inout Hasher) { hasher.combine(id) } }