Cell-File
This commit is contained in:
parent
0dce6e3988
commit
661f8c7dca
@ -14,6 +14,7 @@
|
|||||||
EC13306524DAE92E008063CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EC13306324DAE92E008063CF /* Main.storyboard */; };
|
EC13306524DAE92E008063CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EC13306324DAE92E008063CF /* Main.storyboard */; };
|
||||||
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13306E24DD687F008063CF /* YapsFile.swift */; };
|
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13306E24DD687F008063CF /* YapsFile.swift */; };
|
||||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307024DDB3F4008063CF /* FinderHelper.swift */; };
|
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307024DDB3F4008063CF /* FinderHelper.swift */; };
|
||||||
|
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307324DF2B2D008063CF /* YapsFileCell.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -27,6 +28,7 @@
|
|||||||
EC13306724DAE92E008063CF /* YAPS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = YAPS.entitlements; sourceTree = "<group>"; };
|
EC13306724DAE92E008063CF /* YAPS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = YAPS.entitlements; sourceTree = "<group>"; };
|
||||||
EC13306E24DD687F008063CF /* YapsFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFile.swift; sourceTree = "<group>"; };
|
EC13306E24DD687F008063CF /* YapsFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFile.swift; sourceTree = "<group>"; };
|
||||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderHelper.swift; sourceTree = "<group>"; };
|
EC13307024DDB3F4008063CF /* FinderHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderHelper.swift; sourceTree = "<group>"; };
|
||||||
|
EC13307324DF2B2D008063CF /* YapsFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFileCell.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -59,6 +61,7 @@
|
|||||||
EC13305924DAE92D008063CF /* YAPS */ = {
|
EC13305924DAE92D008063CF /* YAPS */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
EC13307224DF2B05008063CF /* Struct */,
|
||||||
EC13306D24DD685F008063CF /* Model */,
|
EC13306D24DD685F008063CF /* Model */,
|
||||||
EC13305A24DAE92D008063CF /* AppDelegate.swift */,
|
EC13305A24DAE92D008063CF /* AppDelegate.swift */,
|
||||||
EC13305C24DAE92D008063CF /* ContentView.swift */,
|
EC13305C24DAE92D008063CF /* ContentView.swift */,
|
||||||
@ -88,6 +91,14 @@
|
|||||||
path = Model;
|
path = Model;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
EC13307224DF2B05008063CF /* Struct */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
EC13307324DF2B2D008063CF /* YapsFileCell.swift */,
|
||||||
|
);
|
||||||
|
path = Struct;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@ -162,6 +173,7 @@
|
|||||||
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
EC13305D24DAE92D008063CF /* ContentView.swift in Sources */,
|
||||||
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
EC13307124DDB3F4008063CF /* FinderHelper.swift in Sources */,
|
||||||
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */,
|
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */,
|
||||||
|
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */,
|
||||||
EC13305B24DAE92D008063CF /* AppDelegate.swift in Sources */,
|
EC13305B24DAE92D008063CF /* AppDelegate.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
@State var fileList = [YapsFile]()
|
@State var fileList = [YapsFile]()
|
||||||
@State var previewImg = Image("placeholder-image")
|
@State var previewImg = Image("placeholder-image")
|
||||||
|
|
||||||
@ -20,8 +19,12 @@ struct ContentView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
self.fileList.removeAll()
|
let files = self.finderHelper.selectFolder()
|
||||||
self.fileList.append(contentsOf: self.finderHelper.selectFolder())
|
|
||||||
|
if files.count > 0 {
|
||||||
|
self.fileList.removeAll()
|
||||||
|
self.fileList.append(contentsOf: files)
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
Text("Select Folder")
|
Text("Select Folder")
|
||||||
}
|
}
|
||||||
@ -29,21 +32,21 @@ struct ContentView: View {
|
|||||||
|
|
||||||
List {
|
List {
|
||||||
ForEach(self.fileList, id: \.self) { yapsFile in
|
ForEach(self.fileList, id: \.self) { yapsFile in
|
||||||
HStack {
|
YapsFileCell(yapsFile: yapsFile)
|
||||||
self.finderHelper.getImageByFiletype(file: yapsFile.file).resizable().frame(width: 20, height: 20)
|
.focusable()
|
||||||
Text(yapsFile.name)
|
|
||||||
}
|
|
||||||
.onTapGesture(perform: {
|
.onTapGesture(perform: {
|
||||||
let selectedImageURL: URL = yapsFile.file
|
let selectedImageURL: URL = yapsFile.file
|
||||||
|
|
||||||
print("pressed \(yapsFile.name)")
|
print("pressed \(yapsFile.name)")
|
||||||
|
|
||||||
self.previewImg = self.finderHelper.getImageByURL(source: selectedImageURL)
|
self.previewImg = FinderHelper().getImageByURL(source: selectedImageURL)
|
||||||
.resizable()
|
.resizable()
|
||||||
})
|
})
|
||||||
|
.onMoveCommand { (direction) in
|
||||||
|
print("direction: \(direction)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.focusable()
|
|
||||||
}
|
}
|
||||||
.frame(width: 150.0)
|
.frame(width: 150.0)
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,6 @@ import Foundation
|
|||||||
struct YapsFile: Identifiable, Hashable {
|
struct YapsFile: Identifiable, Hashable {
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
|
|
||||||
var name: String
|
let name: String
|
||||||
var file: URL
|
let file: URL
|
||||||
}
|
}
|
||||||
|
|||||||
32
YAPS/YAPS/Struct/YapsFileCell.swift
Normal file
32
YAPS/YAPS/Struct/YapsFileCell.swift
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// YapsFileCell.swift
|
||||||
|
// YAPS
|
||||||
|
//
|
||||||
|
// Created by Gerrit Linnemann on 08.08.20.
|
||||||
|
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct YapsFileCell: View {
|
||||||
|
@State var focused: Bool = false
|
||||||
|
|
||||||
|
var yapsFile : YapsFile
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
// Icon
|
||||||
|
FinderHelper().getImageByFiletype(file: yapsFile.file).resizable().frame(width: 20, height: 20)
|
||||||
|
|
||||||
|
// Text
|
||||||
|
Text(yapsFile.name)
|
||||||
|
.foregroundColor(self.focused ? .red : .green)
|
||||||
|
}
|
||||||
|
.focusable(true, onFocusChange: { (focusChanged) in
|
||||||
|
self.focused = focusChanged
|
||||||
|
print("focus changed \(focusChanged)")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user