Skip to content

Instantly share code, notes, and snippets.

@hrvolapeter
Last active September 9, 2020 20:01
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 hrvolapeter/95a3986e0e8fb6fb0f6e721a2a904b71 to your computer and use it in GitHub Desktop.
Save hrvolapeter/95a3986e0e8fb6fb0f6e721a2a904b71 to your computer and use it in GitHub Desktop.
import Resolver
import SwiftUI
struct NoteListView: View {
@ObservedObject var vm = NoteListViewModel()
var body: some View {
NavigationView {
list
}
}
var list: some View {
List {
ForEach(vm.notes, id: \.note.id) { note in // CHANGE
VStack {
NavigationLink(destination: NoteDetailView(vm: note)){ // CHANGE
NoteRow(note: note.note) // CHANGE
}
}
}
}.navigationBarTitle("Notes")
}
}
struct NoteRow: View {
var note: Note
var body: some View {
VStack(alignment: .leading) {
Text(note.title).padding(.init(top: 0, leading: 0, bottom: 5, trailing: 0))
HStack {
ForEach(note.tags, id: \.self) { tag in
Text(tag)
.font(.footnote)
.padding(3)
.background(Color.accentColor)
.cornerRadius(4)
.foregroundColor(.white)
}.lineLimit(1)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment