List focusable
This commit is contained in:
parent
43ea6556cb
commit
8ff01612a8
@ -42,26 +42,27 @@ struct ContentView: View {
|
|||||||
List {
|
List {
|
||||||
ForEach(self.fileList, id: \.self) { yapsFile in
|
ForEach(self.fileList, id: \.self) { yapsFile in
|
||||||
YapsFileCell(yapsFile: yapsFile)
|
YapsFileCell(yapsFile: yapsFile)
|
||||||
.focusable(true, onFocusChange: { (focusChanged) in
|
.focusable(true, onFocusChange: { (focusChanged) in
|
||||||
//self.focused = focusChanged
|
//self.focused = focusChanged
|
||||||
print("focus changed \(focusChanged)")
|
print("focus changed \(focusChanged)")
|
||||||
})
|
})
|
||||||
.onTapGesture(perform: {
|
.onTapGesture(perform: {
|
||||||
let selectedImageURL: URL = yapsFile.file
|
let selectedImageURL: URL = yapsFile.file
|
||||||
|
|
||||||
print("pressed \(yapsFile.name)")
|
print("pressed \(yapsFile.name)")
|
||||||
|
|
||||||
self.previewImg = FinderHelper.shared.getImageByURL(source: selectedImageURL)
|
self.previewImg = FinderHelper.shared.getImageByURL(source: selectedImageURL)
|
||||||
.resizable()
|
.resizable()
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@ class FinderHelper {
|
|||||||
dialog.showsResizeIndicator = true
|
dialog.showsResizeIndicator = true
|
||||||
dialog.showsHiddenFiles = false
|
dialog.showsHiddenFiles = false
|
||||||
dialog.allowsMultipleSelection = false
|
dialog.allowsMultipleSelection = false
|
||||||
dialog.canChooseFiles = false
|
dialog.canChooseFiles = false
|
||||||
dialog.canChooseDirectories = true
|
dialog.canChooseDirectories = true
|
||||||
|
|
||||||
if(dialog.runModal() == NSApplication.ModalResponse.OK) {
|
if(dialog.runModal() == NSApplication.ModalResponse.OK) {
|
||||||
let result = dialog.url
|
let result = dialog.url
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user