title: How to select an item in ScrollView with SwiftUI?
body: <p>what I am trying to accomplish is have a loop of items where I am able to tap one and it gets bigger programmatically once tapped</p>
  <p>here is my code and my results so far:</p>
  <pre><code>struct ContentView: View {
      
      @State var emojisArray = [&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;]
      @State var selectedIndex = 0
      
      var body: some View {
          VStack {
              ScrollView(.horizontal) {
                  
                  HStack {
                      
                      ForEach(0..&lt;emojisArray.count) { item in
                          
                          
                          emojiView(emoji: self.emojisArray[item],
                                    isSelected: item == self.selectedIndex ? true : false)
                              
                              .onTapGesture {
                                  print (item)
                                  self.selectedIndex = item
                                  
                                  
                          }
                          
                      }
                      
                  }
                  
                  
              }
          .onAppear()
              .frame(height:160)
              
              VStack{
                  Text(&quot;selcted item:&quot;)
                  Text(&quot;\(self.emojisArray[self.selectedIndex])&quot;)
              }
              
          }
          
          
      }
  }
  </code></pre>
  <p>where emojiView is :</p>
  <pre><code>struct emojiView: View {
      
      var emoji : String
      @State var isSelected : Bool
      
      var body: some View {
          Text(emoji)
              .font(isSelected ? .system(size: 120) : .system(size: 45))
      }
  }
  
  </code></pre>
  <p>I guess the problem is that the ScrollView does't reload itself</p>
  <p><a href="https://i.stack.imgur.com/Aca71.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Aca71.png" alt="enter image description here" /></a></p>