title: SwiftUI segmented control - how to switch to other segment on tap in first segment?
body: <p>I have a segmentedControl (<code>Picker</code>) with two segments:</p>
  <pre class="lang-swift prettyprint-override"><code>struct Container: View {    
      @State private var selectedSegment: Segment = .first
      
      var body: some View {
          VStack {
              Picker(&quot;&quot;, selection: $selectedSegment) {
                  ForEach(Segment.allCases, id: \.self) {
                      Text($0.rawValue)
                  }
              }
              .pickerStyle(.segmented)
              .padding()
              Spacer()
              SegmentView(segment: selectedSegment)
              Spacer()
          }
      }
  }
  
  struct SegmentView: View {
      var segment: Segment
      
      var body: some View {
          switch segment {
          case .first:
              FirstView()
          case .features:
              FeaturesView()
          }
      }
  }
  </code></pre>
  <p>In one of the segments I show a list:</p>
  <pre class="lang-swift prettyprint-override"><code>struct FeaturesView: View {
      private var features: [Feature]
          
      var body: some View {
          VStack {
              List(features) { feature in
                  FeatureRow(feature: feature)
                      .onTapGesture {
                          // switch to other segment and pass in `feature`
                      }
              }
              .listStyle(PlainListStyle())
          }
      }
  }
  </code></pre>
  <p>What I am trying to do is when the user taps on one of the rows in <code>FeaturesView</code>, switch to <code>FirstView</code> and pass in the <code>feature</code>.</p>
  <p>How do I do this is <code>SwiftUI</code> ?</p>
  <p>Maybe by using a <code>Notification</code> ?</p>