mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-24 10:21:28 +01:00
Just a couple of Combine Publishers to go.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user