title: (SwiftUI) How to make text hidden when view loads and become visible once toggle is tapped
body: <p>I'm trying to create a view with a <code>toggle</code>. the toggle changes ui preferences. when the toggle is changed it changes the <code>Text</code> below. as it stands the easiest way to do this is</p>
  <pre><code>        VStack {
              Toggle(&quot;toggle me&quot;, isOn: $isOn)
              Text( isOn ? &quot;I've been toggled once more&quot; : &quot;I've been toggled again&quot; )
           }
  </code></pre>
  <p>what I would like is for the <code>Text( isOn ? &quot;I've been toggled once more&quot; : &quot;I've been toggled again&quot; )</code> to be hidden until <em>after</em> the toggle is interacted with. it doesn't matter if it's been toggled on or off, I would like to make the Text visible once the toggle has been interacted with. I've tried to use the <code>.onChange(of: perform: )</code> but <code>perform: </code> requires a void method. so I can't put the Text in there. I have tried using a boolean/opacity fix as shown in the answer <a href="https://stackoverflow.com/questions/58276635/swiftui-setting-view-visibility-based-on-a-property-value">here</a> but same problem. can't change a Boolean value in perform. only void methods are allowed. I did try to use <code>onTapGesture</code> but that didn't work at all. I had a print statement in there that never once printed. not sure what else to do. is it possible to keep text hidden until the toggle has been interacted with? here's my code</p>
  <pre><code>struct ProfileView: View {
      
      @State private var isOn = UserDefaults.standard.bool(forKey: &quot;isOn&quot;)
      @State private var showText = false
      
      var body: some View {
          VStack { // vstack 0
              Text(&quot;Profile Page&quot;)
                  .font(.title)
              
              Text(&quot;Are you ready to toggle?&quot;)
                  .font(.title2)
                  .multilineTextAlignment(.center)
              
              VStack { // vstack 1
                  Toggle(&quot;toggle this&quot;, isOn: $isOn)
                      .onTapGesture {
                          print(&quot;toggled&quot;) // this never prints
                      }
  //                    .onChange(of: isOn, perform: { value in
  //                        value ? Text(&quot;yes&quot;) : Text(&quot;no&quot;)
  //                        print(&quot;value = \(value)&quot;)
  //                    })
  // the Text here never shows up. and can't set showText = true here
                  Text( isOn ? &quot;Thank you.&quot; : &quot;Toggled again&quot; )
                      .opacity(showText ? 1 : 0)
  // from the linked stackoverflow answer. trying to make this boolean work. is it a lost cause? 
              } // vstack 1
          } // vstack 0
          .frame(
              width: UIScreen.main.bounds.width,
              height: UIScreen.main.bounds.height - 200,
              alignment: .top)
      }
  }
  </code></pre>
  <p>So is what I'm asking even possible? Thanks for the help!</p>