//
//  ContentView.swift
//  Subtasks
//

import Adwaita

struct ContentView: WindowView {

    @State("tasks") private var tasks: [Task] = []
    @State private var destination: NavigationStack<Binding<Task>> = .init()
    var app: AdwaitaApp

    var view: Body {
        NavigationView($destination, "Subtasks") { task in
            TaskList(tasks: task.subtasks, destination: $destination, app: app) {
                tasks.delete(id: task.wrappedValue.id)
                destination.pop()
            }
        } initialView: {
            TaskList(tasks: $tasks, destination: $destination, app: app)
        }
    }

    func window(_ window: Window) -> Window {
        window
    }

}
