I've spent soooooooo much time trying to work this out and I still have NO IDEA how to do this......
Where do I put the button or navigation link or ontap gesture to make my items (Humanity, Globel, et cetera) clickable so that they show a new screen?
Can someone pleeeeeaaaaase help me?
This code comes from SwiftUI Tutorial: Searchable. Create a search bar with only few lines… | by Arc Sosangyo | Geek Culture | Medium
import SwiftUI
struct ContentView: View {
@State var searchCollection = collections
@State private var searchText = ""
var body: some View {
NavigationView {
List(searchCollection) { index in
//Button("Button 1") { }
ImageLabelRow(collection: index)
}
.navigationTitle("Title")
}
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))
.onChange(of: searchText) { index in
if !index.isEmpty {
searchCollection = collections.filter { $0.name.contains(index) }
} else {
searchCollection = collections
}
}
} //body
} //ContentView
struct Collections: Identifiable
{
var id = UUID()
var name: String
}
var collections = [
Collections(name: "Humanity"),
Collections(name: "Global"),
Collections(name: "Energy"),
Collections(name: "Nature"),
Collections(name: "Weather"),
Collections(name: "Travel"),
Collections(name: "Video Games"),
Collections(name: "Health"),
]
struct ImageLabelRow: View {
var collection: Collections
var body: some View {
HStack {
Text(collection.name)
//.font(.system(.largeTitle, design: .rounded))
//.fontWeight(.black)
}
}
}