title: SwiftUI Show Sheets From Buttons Not Working With Multiple Buttons
body: <p>I have multiple buttons and depending on what button is pressed, I want a sheet to open and go to a certain view based on what button is pressed. I have this working to some extent, except there is one problem that I cannot figure out a solution to. The first button that I press does not work. It simply shows the first task from the list that has been declared by the <code>@State var CurrentSheetView</code> below:</p>
  <p><code>@State var showingSheet = false</code></p>
  <p><code>@State var CurrentSheetView: Int = 0</code></p>
  <p>If you continue to pull down the sheet and reselect the same button that you first pressed, it does the same thing. However, if you select another button, that works. After that, all buttons work as intended. Why is this happening?</p>
  <p>Here is my other code that is apart of another view from the first couple <code>@State</code>s:</p>
  <pre><code>ButtonToTrackView(tasknumber: SuggestedNumber1, newsheetview: &quot;SuggestedNumber1&quot;)
                      
                      ButtonToTrackView(tasknumber: SuggestedNumber2, newsheetview: &quot;SuggestedNumber2&quot;)
                      
                      ButtonToTrackView(tasknumber: SuggestedNumber3, newsheetview: &quot;SuggestedNumber3&quot;)
                      
                      ButtonToTrackView(tasknumber: SuggestedNumber4, newsheetview: &quot;SuggestedNumber4&quot;)
                      
                      ButtonToTrackView(tasknumber: SuggestedNumber5, newsheetview: &quot;SuggestedNumber5&quot;)
                      
                      ButtonToTrackView(tasknumber: SuggestedNumber6, newsheetview: &quot;SuggestedNumber6&quot;)
                          .sheet(isPresented: $showingsheet, content: {
                              DetailedTrackView(sfsymbolname: task[CurrentSheetView].sfsymbolname, taskname: task[CurrentSheetView].taskname, taskdetails: task[CurrentSheetView].taskdescription, tokencount: task[CurrentSheetView].tokencount, DailyGoalProgress: $DailyGoalProgress, TabSelection: $TabSelection)
                          })
  </code></pre>
  <p>and here is the function <code>ButtonToTrackView</code> that is used above:</p>
  <pre><code>func ButtonToTrackView(tasknumber: Int, newsheetview: String) -&gt; some View {
      Button(action: { CurrentSheetView = tasknumber; showingsheet.toggle(); print(CurrentSheetView); print(showingsheet)}, label: {
          TrackBlockView(sfimagename: task[tasknumber].sfsymbolname, taskname: task[tasknumber].taskname, tokencount: String(task[tasknumber].tokencount))
      })
      
  }
  </code></pre>
  <p>The &quot;Suggested Numbers&quot; are randomly generated <code>@State</code>s that are used to select from a list of possible tasks.</p>
  <p>Thanks for reading this and any help would really be appreciated.</p>