The variable from SignInController changes, the view does not.
import SwiftUI
import Foundation
class SignInController: ObservableObject {
var signedIn: Bool = false
}
struct MainView: View {
@StateObject var signCon = SignInController()
var body: some View {
return Group {
if signCon.signedIn == false {
ZStack {
SignView()
Button {
signCon.signedIn.toggle()
print(signCon.signedIn)
} label: {
Text("Make True")
}
}
}
else if signCon.signedIn == true {
HomeView()
}
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
}
}
extension UserDefaults {
func valueExists(forKey key: String) -> Bool {
return object(forKey: key) != nil
}
}