diff --git a/apple/OmnivoreKit/Sources/Binders/PrimaryContentCategory.swift b/apple/OmnivoreKit/Sources/Binders/PrimaryContentCategory.swift index 3b133c876..46d73436d 100644 --- a/apple/OmnivoreKit/Sources/Binders/PrimaryContentCategory.swift +++ b/apple/OmnivoreKit/Sources/Binders/PrimaryContentCategory.swift @@ -1,6 +1,7 @@ import SwiftUI import Views +// TODO: maybe this can be removed?? enum PrimaryContentCategory: Identifiable, Hashable, Equatable { case feed(viewModel: HomeFeedViewModel) case profile(viewModel: ProfileContainerViewModel) @@ -31,15 +32,6 @@ enum PrimaryContentCategory: Identifiable, Hashable, Equatable { } } - var selectedImage: Image { - switch self { - case .feed: - return .homeTabSelected - case .profile: - return .profileTabSelected - } - } - var listLabel: some View { Label { Text(title) } icon: { image.renderingMode(.template) } } diff --git a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift index 9259d3f65..6957d492d 100644 --- a/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift +++ b/apple/OmnivoreKit/Sources/Binders/RootViewModel.swift @@ -185,6 +185,8 @@ public struct RootView: View { .frame(minWidth: 400, idealWidth: 1200, minHeight: 400, idealHeight: 1200) #endif } + .environmentObject(viewModel.services.authenticator) + .environmentObject(viewModel.services.dataService) #if os(iOS) .onOpenURL { url in withoutAnimation { diff --git a/apple/OmnivoreKit/Sources/Binders/Services.swift b/apple/OmnivoreKit/Sources/Binders/Services.swift index 041dc7298..c73ff44bb 100644 --- a/apple/OmnivoreKit/Sources/Binders/Services.swift +++ b/apple/OmnivoreKit/Sources/Binders/Services.swift @@ -11,9 +11,4 @@ public final class Services { self.authenticator = Authenticator(networker: networker) self.dataService = DataService(appEnvironment: appEnvironment, networker: networker) } - - public func switchAppEnvironment(to appEnvironment: AppEnvironment) { - authenticator.logout() - dataService.switchAppEnvironment(appEnvironment: appEnvironment) - } } diff --git a/apple/OmnivoreKit/Sources/Binders/Views/DebugMenuView.swift b/apple/OmnivoreKit/Sources/Binders/Views/DebugMenuView.swift index 78cbb2308..33feeb86a 100644 --- a/apple/OmnivoreKit/Sources/Binders/Views/DebugMenuView.swift +++ b/apple/OmnivoreKit/Sources/Binders/Views/DebugMenuView.swift @@ -1,16 +1,17 @@ import Models +import Services import SwiftUI import Views struct DebugMenuView: View { + @EnvironmentObject var authenticator: Authenticator + @EnvironmentObject var dataService: DataService @State private var selectedEnvironment: AppEnvironment let appEnvironments: [AppEnvironment] = [.local, .demo, .dev, .prod] - let services: Services - init(services: Services) { - self._selectedEnvironment = State(initialValue: services.dataService.appEnvironment) - self.services = services + init(initialEnvironment: AppEnvironment) { + self._selectedEnvironment = State(initialValue: initialEnvironment) } var body: some View { @@ -28,7 +29,10 @@ struct DebugMenuView: View { } Button( - action: { services.switchAppEnvironment(to: selectedEnvironment) }, + action: { + authenticator.logout() + dataService.switchAppEnvironment(appEnvironment: selectedEnvironment) + }, label: { Text("Apply Changes") } ) .buttonStyle(SolidCapsuleButtonStyle(width: 220)) diff --git a/apple/OmnivoreKit/Sources/Binders/Views/WelcomeView.swift b/apple/OmnivoreKit/Sources/Binders/Views/WelcomeView.swift index 4b7d701b1..f88e7983e 100644 --- a/apple/OmnivoreKit/Sources/Binders/Views/WelcomeView.swift +++ b/apple/OmnivoreKit/Sources/Binders/Views/WelcomeView.swift @@ -5,6 +5,7 @@ import Utils import Views struct WelcomeView: View { + @EnvironmentObject var dataService: DataService @Environment(\.horizontalSizeClass) var horizontalSizeClass let services: Services @State private var showRegistrationView = false @@ -76,7 +77,7 @@ struct WelcomeView: View { public var body: some View { primaryContent() .sheet(isPresented: $showDebugModal) { - DebugMenuView(services: services) + DebugMenuView(initialEnvironment: dataService.appEnvironment) } .onReceive(Publishers.keyboardHeight) { isKeyboardOnScreen = $0 > 1 } } diff --git a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift index 4cf69272e..12deb1da3 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/DataService.swift @@ -1,7 +1,7 @@ import Foundation import Models -public final class DataService { +public final class DataService: ObservableObject { public static var registerIntercomUser: ((String) -> Void)? public static var showIntercomMessenger: (() -> Void)?