List focusable

This commit is contained in:
Gerrit Linnemann 2020-08-12 20:19:24 +02:00
parent 43ea6556cb
commit 8ff01612a8
3 changed files with 22 additions and 20 deletions

View File

@ -56,12 +56,13 @@ struct ContentView: View {
Shared.shared.currentFile = yapsFile Shared.shared.currentFile = yapsFile
}) })
.onMoveCommand { (direction) in
print("direction: \(direction)")
}
} }
} }
.listStyle(SidebarListStyle()) .listStyle(SidebarListStyle())
.focusable()
.onMoveCommand { (direction) in
print("direction: \(direction)")
}
} }
.frame(width: 200.0) .frame(width: 200.0)
@ -73,7 +74,7 @@ struct ContentView: View {
} }
} }
Text("\(Shared.shared.currentFile.file.absoluteString)") Text("\(Shared.shared.currentFile.file.path)")
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.lineLimit(1) .lineLimit(1)
} }

View File

@ -10,6 +10,7 @@ import Foundation
class Shared: ObservableObject { class Shared: ObservableObject {
static let shared = Shared() static let shared = Shared()
var currentFile: YapsFile = YapsFile(name: "EMPTY", file: .init(fileURLWithPath: "Y")) var currentFile: YapsFile = YapsFile(name: "EMPTY", file: .init(fileURLWithPath: "Y"))
var destination: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] var destination: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
var destinationDefined: Bool = false var destinationDefined: Bool = false