title: How to change a @State variable from a different struct
body: <p>I am new to swift UI and swift in general, and I was wondering how to change a variable from a different struct. In this case, I need to change the logged in boolean in a content view from this section in a different view. Basic explanations would be appreciated. Thanks!</p>
  
  <pre class="lang-swift prettyprint-override"><code>Button(action: {
  
      if (checkKey(testKey: self.key)) {
  
          //HERE
  
      }
  
  }) {
      Text("Submit")
      .padding()
  .background(Color.init(.sRGB, red: 0.01, green: 0.01, blue: 0.01, opacity: 0.05))
              .cornerRadius(10)
  }
  </code></pre>
  
  <p>And this is the Content View. I need to change the @State bool</p>
  
  <pre><code>struct ContentView: View {
  
      @State public var loggedin: Bool = false
  
      var body: some View {
  
          NavigationView {
  
              if (loggedin) {
  
                  MainView()
  
              } else {
                  // Not Logged In
                  LoginScreen()
              }
          }
      }
  }
  </code></pre>