Clicks not working as taps in Xcode preview?

38 Views Asked by At

I followed a cool YouTube tutorial to make a random TabBar and initially it was all working just fine and then something happened and the taps now are just inert. Nothing happens!

I tried changing the target architecture in build settings but nothing helped. Is the code somehow bad (it looks materially identical to the video's) or is Xcode just...?

import SwiftUI

enum ActionIcon: String, CaseIterable {
  case Home = "house"
  case Library = "books.vertical"
  case Performer = "dot.radiowaves.left.and.right"
  case Editor = "dial.medium"
  case Comms = "bolt.horizontal.circle"
  //case Prefs = "gearshape"
}

struct NavBar: View {
  @Binding var selectedTab: ActionIcon
  
  private var selectedIcon: String {
    if selectedTab != .Performer {
      return selectedTab.rawValue+".fill"
    } else {
      return selectedTab.rawValue
    }
  }
  
  var body: some View {
    VStack {
      HStack {
        ForEach(ActionIcon.allCases, id:\.rawValue) { tab in
          Spacer()
          Image(systemName: selectedTab == tab ? selectedIcon : tab.rawValue )
            .scaleEffect(tab == selectedTab ? 1.28  : 1.0)
            .foregroundColor(tab == selectedTab ? Color("GROrange"): Color.primary)
            .font(.system(size:18))
            .onTapGesture {
              withAnimation(.easeIn(duration:0.1)) {
                selectedTab = tab
              }
            }
          Spacer()
        }
      }
      .frame(height: 60)
      .background(.ultraThinMaterial)
      .cornerRadius(50)
      .padding()
    }
  }
}

struct NavBar_Previews: PreviewProvider {
  static var previews: some View {
    @State var stab:ActionIcon = .Library
    return NavBar(selectedTab: $stab)
  }
}
0

There are 0 best solutions below