Selektieren des Fotos per Pfeiltaste
This commit is contained in:
parent
9b276f55d2
commit
641b1bf0fd
@ -13,73 +13,81 @@ struct ContentView: View {
|
|||||||
@State var previewImg = Image("placeholder-image")
|
@State var previewImg = Image("placeholder-image")
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
HStack {
|
||||||
HStack {
|
VStack(alignment: .leading) {
|
||||||
NavigationView {
|
Button(action: {
|
||||||
VStack(alignment: .leading) {
|
let files = FinderHelper.shared.askForFolderAndGetFiles()
|
||||||
HStack {
|
|
||||||
Button(action: {
|
if files.count > 0 {
|
||||||
let files = FinderHelper.shared.askForFolderAndGetFiles()
|
self.fileList.removeAll()
|
||||||
|
self.fileList.append(contentsOf: files)
|
||||||
if files.count > 0 {
|
|
||||||
self.fileList.removeAll()
|
|
||||||
|
|
||||||
self.fileList.append(contentsOf: files)
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
Text("Select Folder")
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(action: {
|
|
||||||
if !Shared.shared.destinationDefined {
|
|
||||||
Shared.shared.destination = FinderHelper.shared.selectFolder(modalTitle: "Choose destination folder.")
|
|
||||||
Shared.shared.destinationDefined = true
|
|
||||||
}
|
|
||||||
FinderHelper.shared.iLikeThisImage(yapsFile: Shared.shared.currentFile, destination: Shared.shared.destination)
|
|
||||||
}) {
|
|
||||||
Text("Get It!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List {
|
self.resetCurrentFile()
|
||||||
ForEach(self.fileList, id: \.self) { yapsFile in
|
|
||||||
YapsFileCell(focused: self.checkCurrentFile(yapsFile: yapsFile), yapsFile: yapsFile)
|
|
||||||
.onTapGesture(perform: {
|
|
||||||
print("pressed \(yapsFile.name)")
|
|
||||||
|
|
||||||
self.previewImg = FinderHelper.shared.getImageByURL(source: yapsFile.file)
|
|
||||||
.resizable()
|
|
||||||
|
|
||||||
Shared.shared.currentFile = yapsFile
|
|
||||||
|
|
||||||
self.resetCurrentFile()
|
|
||||||
self.fileList[yapsFile.index].current = true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.listStyle(SidebarListStyle())
|
}) {
|
||||||
}
|
Text("Select Folder")
|
||||||
.focusable()
|
|
||||||
.onMoveCommand { (direction) in
|
|
||||||
print("direction: \(direction)")
|
|
||||||
print("#\(Shared.shared.currentFile.index) :: \(Shared.shared.currentFile.name)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GeometryReader { geo in
|
List {
|
||||||
|
ForEach(self.fileList, id: \.self) { yapsFile in
|
||||||
|
YapsFileCell(focused: self.checkCurrentFile(yapsFile: yapsFile), yapsFile: yapsFile)
|
||||||
|
.onTapGesture(perform: {
|
||||||
|
print("pressed \(yapsFile.name)")
|
||||||
|
|
||||||
|
self.previewImg = FinderHelper.shared.getImageByURL(source: yapsFile.file)
|
||||||
|
.resizable()
|
||||||
|
|
||||||
|
Shared.shared.currentFile = yapsFile
|
||||||
|
|
||||||
|
self.resetCurrentFile()
|
||||||
|
self.fileList[yapsFile.index].current = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.listStyle(SidebarListStyle())
|
||||||
|
.focusable()
|
||||||
|
.onMoveCommand { (direction) in
|
||||||
|
var newIndex = Shared.shared.currentFile.index
|
||||||
|
|
||||||
|
switch direction {
|
||||||
|
case MoveCommandDirection.down:
|
||||||
|
newIndex += 1
|
||||||
|
case MoveCommandDirection.up:
|
||||||
|
newIndex -= 1
|
||||||
|
default:
|
||||||
|
newIndex += 0
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentFile = self.fileList[newIndex]
|
||||||
|
|
||||||
|
Shared.shared.currentFile = currentFile
|
||||||
|
|
||||||
|
self.resetCurrentFile()
|
||||||
|
self.fileList[newIndex].current = true
|
||||||
|
|
||||||
|
self.previewImg = FinderHelper.shared.getImageByURL(source: self.fileList[newIndex].file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(width: 200.0)
|
||||||
|
|
||||||
|
|
||||||
|
GeometryReader { geo in
|
||||||
|
VStack(alignment: .center) {
|
||||||
self.previewImg.self
|
self.previewImg.self
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fit)
|
||||||
.frame(width: geo.size.width)
|
|
||||||
|
Text("\(Shared.shared.currentFile.file.path)")
|
||||||
|
.multilineTextAlignment(.leading)
|
||||||
|
.lineLimit(1)
|
||||||
}
|
}
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.frame(width: geo.size.width, height: geo.size.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
Text("\(Shared.shared.currentFile.file.path)")
|
|
||||||
.multilineTextAlignment(.leading)
|
|
||||||
.lineLimit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func checkCurrentFile(yapsFile: YapsFile) -> Bool {
|
func checkCurrentFile(yapsFile: YapsFile) -> Bool {
|
||||||
let result: Bool = (Shared.shared.currentFile.index == yapsFile.index)
|
let result: Bool = (Shared.shared.currentFile.index == yapsFile.index)
|
||||||
if result {
|
if result {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user