-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskView.swift
More file actions
61 lines (55 loc) · 1.8 KB
/
TaskView.swift
File metadata and controls
61 lines (55 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// TaskView.swift
// CoreDataToDo
//
// Created by Samantha So on 2020-08-14.
// Copyright © 2020 Courtney Loui. All rights reserved.
//
import SwiftUI
struct TaskView: View {
@Environment(\.managedObjectContext) var managedObjectContext
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@FetchRequest(fetchRequest: ToDoItem.getAllToDoItems()) var toDoItems:FetchedResults<ToDoItem>
var title:String = ""
var createdAt:String = ""
var completed:Bool = false
// @State private var title = ""
// @State private var createdAt = Date()
var body: some View {
// NavigationView {
List {
Section(header: Text("Task")) {
HStack {
VStack { Text(title).font(.headline) }
}
}.font(.headline)
Section(header: Text("Date and Time")) {
HStack {
VStack { Text(createdAt).font(.headline) }
}
}
Section(header: Text("Completed")) {
HStack {
VStack { Text(completed ? "Complete" : "Incomplete").font(.headline)}
}
}
}
// }.navigationBarItems(
// trailing: Button(action: {
// print("Done")
// }) {
// Text("Done")
// }
/*
leading: Button("Cancel", action: {
self.presentationMode.wrappedValue.dismiss()
})
*/
// }
}
}
struct TaskView_Previews: PreviewProvider {
static var previews: some View {
TaskView(title: "To Do", createdAt: "Today", completed: false)
}
}