From da70e40c6aa9850bf9fb8c1395f0ad8bbd6c609a Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Mon, 28 Feb 2022 12:32:42 -0800 Subject: [PATCH] pass in appenv binding to debug view --- apple/OmnivoreKit/Sources/App/Views/DebugMenuView.swift | 5 +---- apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/DebugMenuView.swift b/apple/OmnivoreKit/Sources/App/Views/DebugMenuView.swift index 597a36bdf..6b6f83eae 100644 --- a/apple/OmnivoreKit/Sources/App/Views/DebugMenuView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/DebugMenuView.swift @@ -6,7 +6,7 @@ import Views struct DebugMenuView: View { @EnvironmentObject var authenticator: Authenticator @EnvironmentObject var dataService: DataService - @State private var selectedEnvironment = AppEnvironment.dev + @Binding var selectedEnvironment: AppEnvironment let appEnvironments: [AppEnvironment] = [.local, .demo, .dev, .prod] @@ -34,8 +34,5 @@ struct DebugMenuView: View { .buttonStyle(SolidCapsuleButtonStyle(width: 220)) } .padding() - .onAppear { - selectedEnvironment = dataService.appEnvironment - } } } diff --git a/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift b/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift index d3db63a49..96a5e7521 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift @@ -1,4 +1,5 @@ import Combine +import Models import Services import SwiftUI import Utils @@ -10,6 +11,7 @@ struct WelcomeView: View { @State private var showRegistrationView = false @State private var isKeyboardOnScreen = false @State private var showDebugModal = false + @State private var selectedEnvironment = AppEnvironment.initialAppEnvironment func handleHiddenGestureAction() { if !Bundle.main.isAppStoreBuild { @@ -76,8 +78,9 @@ struct WelcomeView: View { public var body: some View { primaryContent() .sheet(isPresented: $showDebugModal) { - DebugMenuView() + DebugMenuView(selectedEnvironment: $selectedEnvironment) } .onReceive(Publishers.keyboardHeight) { isKeyboardOnScreen = $0 > 1 } + .onAppear { selectedEnvironment = dataService.appEnvironment } } }