Basic views added.
Next step is to build the feed item list once a parser has been found/
made.
Signed-off-by: Louis Hollingworth <louis@hollingworth.ch>
This commit is contained in:
parent
9701c3428c
commit
a18f485502
3 changed files with 93 additions and 8 deletions
|
|
@ -10,16 +10,46 @@ import CoreData
|
|||
|
||||
struct ContentView: View {
|
||||
@Environment(\.managedObjectContext) var moc
|
||||
|
||||
@FetchRequest(sortDescriptors: [], animation: .default) var feeds: FetchedResults<Feed>
|
||||
|
||||
@State private var showAddScreen = false
|
||||
|
||||
var body: some View {
|
||||
Text("Hello World")
|
||||
NavigationView {
|
||||
List {
|
||||
ForEach(feeds) { item in
|
||||
Text(item.name!)
|
||||
}
|
||||
.onDelete(perform: deleteItems)
|
||||
}
|
||||
.navigationTitle("feeds")
|
||||
.toolbar {
|
||||
ToolbarItem {
|
||||
Button(action: {
|
||||
showAddScreen.toggle()
|
||||
}) {
|
||||
Label("add", systemImage: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showAddScreen) {
|
||||
AddFeed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addItem() {}
|
||||
|
||||
func deleteItems() {}
|
||||
func deleteItems(offsets: IndexSet) {
|
||||
withAnimation {
|
||||
offsets.map { feeds[$0] }.forEach(moc.delete)
|
||||
|
||||
do {
|
||||
try moc.save()
|
||||
} catch {
|
||||
let err = error as NSError
|
||||
fatalError("Unresolved error \(err), \(err.userInfo)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue