Skip to content

Instantly share code, notes, and snippets.

@hrvolapeter
Last active September 6, 2020 07:42
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/375b829588f4549c986b6bc58352ea4a to your computer and use it in GitHub Desktop.
Save hrvolapeter/375b829588f4549c986b6bc58352ea4a to your computer and use it in GitHub Desktop.
zetten note list
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) { note in
VStack {
NoteRow(note: note)
}
}
}.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