struct ContentView: View {
   @State private var appData = ApplicationData.shared
   @State private var openSheet: Bool = false

   var body: some View {
      NavigationStack {
         List {
            ForEach(appData.listOfFiles) { file in
               NavigationLink(destination: EditDocumentView(selectedFile: file)) {
                  Text(file.name)
               }
            }
            .onDelete { indexes in
               Task {
                  await appData.removeFiles(indexes: indexes)
               }
            }
         }
         .navigationBarTitle("List of Files")
         .toolbarTitleDisplayMode(.inline)
         .toolbar {
            ToolbarItem(placement: .topBarTrailing) {
               Button(action: {
                  openSheet = true
               }, label: {
                  Image(systemName: "plus")
               }).buttonStyle(.borderedProminent)
            }
         }
         .sheet(isPresented: $openSheet) {
            CreateFileView()
         }
      }
   }
}