Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created January 22, 2021 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azamsharp/936f8abc4b913c12bdddd86042071805 to your computer and use it in GitHub Desktop.
Save azamsharp/936f8abc4b913c12bdddd86042071805 to your computer and use it in GitHub Desktop.
import SwiftUI
struct CustomerListView: View {
let customers: [String]
var body: some View {
List(customers, id: \.self) { customer in
NavigationLink(
destination: DetailView(customer: customer),
label: {
HStack {
Text(customer)
Spacer()
}.contentShape(Rectangle())
})
}.listStyle(PlainListStyle())
}
}
struct CustomersView_Previews: PreviewProvider {
static var previews: some View {
CustomerListView(customers: ["John", "Mary", "Alex"])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment