Just a couple of Combine Publishers to go.

This commit is contained in:
John Holdsworth
2019-07-09 14:43:52 +01:00
parent b8281e5e21
commit f5f4d0b3d5
12 changed files with 33 additions and 24 deletions

View File

@@ -20,12 +20,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
// Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: NavigationView {
TaskListView().environmentObject(UserData())
})
self.window = window
window.makeKeyAndVisible()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: TaskListView().environmentObject(UserData()))
self.window = window
window.makeKeyAndVisible()
}
}
func sceneDidDisconnect(_ scene: UIScene) {

View File

@@ -22,7 +22,7 @@ struct TaskItemView: View {
.tapAction(count: 1) {
self.delete()
}
NavigationButton(destination: TaskEditView(task: task).environmentObject(self.userData)) {
NavigationLink(destination: TaskEditView(task: task).environmentObject(self.userData)) {
Text(task.title)
}
} else {

View File

@@ -14,13 +14,14 @@ struct TaskListView: View {
@State var isEditing: Bool = false
var body: some View {
NavigationView {
List {
TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask)
ForEach(self.userData.tasks) { task in
TaskItemView(task: task, isEditing: self.$isEditing)
}
}
.navigationBarItem(title: Text("Tasks 👀"))
.navigationBarTitle(Text("Tasks 👀"))
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
if !self.isEditing {
Text("Edit")
@@ -28,6 +29,7 @@ struct TaskListView: View {
Text("Done").bold()
}
})
}
}
private func createTask() {