move primary content view into binders package
This commit is contained in:
@ -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") {
|
||||
|
||||
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user