Last active
September 9, 2020 20:01
-
-
Save hrvolapeter/95a3986e0e8fb6fb0f6e721a2a904b71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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