Ausgabe des Änderungsdatums zu einer Datei
This commit is contained in:
parent
bc3da08d0c
commit
e8760f5245
@ -17,6 +17,7 @@
|
||||
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC13307324DF2B2D008063CF /* YapsFileCell.swift */; };
|
||||
ECF5A75824E070710010A11D /* RawFileExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A75724E070710010A11D /* RawFileExtensions.swift */; };
|
||||
ECF5A76024E41AAC0010A11D /* Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A75F24E41AAC0010A11D /* Shared.swift */; };
|
||||
ECF5A76224E93C080010A11D /* MiscHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = ECF5A76124E93C080010A11D /* MiscHelper.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -33,6 +34,7 @@
|
||||
EC13307324DF2B2D008063CF /* YapsFileCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YapsFileCell.swift; sourceTree = "<group>"; };
|
||||
ECF5A75724E070710010A11D /* RawFileExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RawFileExtensions.swift; sourceTree = "<group>"; };
|
||||
ECF5A75F24E41AAC0010A11D /* Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shared.swift; sourceTree = "<group>"; };
|
||||
ECF5A76124E93C080010A11D /* MiscHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MiscHelper.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -76,6 +78,7 @@
|
||||
EC13306024DAE92E008063CF /* Preview Content */,
|
||||
EC13307024DDB3F4008063CF /* FinderHelper.swift */,
|
||||
ECF5A75F24E41AAC0010A11D /* Shared.swift */,
|
||||
ECF5A76124E93C080010A11D /* MiscHelper.swift */,
|
||||
);
|
||||
path = YAPS;
|
||||
sourceTree = "<group>";
|
||||
@ -183,6 +186,7 @@
|
||||
EC13306F24DD687F008063CF /* YapsFile.swift in Sources */,
|
||||
EC13307424DF2B2D008063CF /* YapsFileCell.swift in Sources */,
|
||||
EC13305B24DAE92D008063CF /* AppDelegate.swift in Sources */,
|
||||
ECF5A76224E93C080010A11D /* MiscHelper.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@ -60,7 +60,7 @@ struct ContentView: View {
|
||||
self.setCurrentFile(newCurrent: self.fileList[newIndex], at: newIndex)
|
||||
}
|
||||
}
|
||||
.frame(width: 200.0)
|
||||
.frame(width: 260.0)
|
||||
|
||||
|
||||
GeometryReader { geo in
|
||||
|
||||
@ -65,7 +65,7 @@ class FinderHelper {
|
||||
}
|
||||
|
||||
func getImageByFiletype(file: URL) -> Image {
|
||||
let fileExtension = file.pathExtension
|
||||
let fileExtension = file.pathExtension.lowercased()
|
||||
var image = Image("file")
|
||||
|
||||
switch fileExtension {
|
||||
@ -150,6 +150,19 @@ class FinderHelper {
|
||||
return URL(fileURLWithPath: fullPathRAW)
|
||||
}
|
||||
|
||||
func getFileAttributes(yapsFile: YapsFile) -> [FileAttributeKey: Any] {
|
||||
var attributes: [FileAttributeKey: Any] = [FileAttributeKey: Any]()
|
||||
|
||||
do {
|
||||
attributes = try FileManager.default.attributesOfItem(atPath: yapsFile.file.path)
|
||||
}
|
||||
catch let error as NSError {
|
||||
print("Ooops! Something went wrong: \(error)")
|
||||
}
|
||||
|
||||
return attributes
|
||||
}
|
||||
|
||||
func listMounts() -> [URL] {
|
||||
var mounts: [URL] = [URL]()
|
||||
|
||||
@ -162,7 +175,7 @@ class FinderHelper {
|
||||
&& components[1] == "Volumes"
|
||||
&& !(components[2].contains("ime") && components[2].contains("achine")) // skip TimeMachine ^^
|
||||
{
|
||||
print(url)
|
||||
print("Found moung at \(url)")
|
||||
mounts.append(url)
|
||||
}
|
||||
}
|
||||
|
||||
30
YAPS/YAPS/MiscHelper.swift
Normal file
30
YAPS/YAPS/MiscHelper.swift
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// MiscHelper.swift
|
||||
// YAPS
|
||||
//
|
||||
// Created by Gerrit Linnemann on 16.08.20.
|
||||
// Copyright © 2020 Adawim UG (haftungsbeschränkt). All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class MiscHelper {
|
||||
static let shared = MiscHelper()
|
||||
|
||||
private init() { }
|
||||
|
||||
func dateFormatDefault(inDate: Date) -> String {
|
||||
let dateFormatterGet = DateFormatter()
|
||||
dateFormatterGet.dateFormat = "yyyy-MM-dd HH:mm:ss"
|
||||
|
||||
let dateFormatterPrint = DateFormatter()
|
||||
dateFormatterPrint.dateFormat = "yyyy.MM.dd"
|
||||
|
||||
if let date = dateFormatterGet.date(from: dateFormatterGet.string(from: inDate)) {
|
||||
return dateFormatterPrint.string(from: date)
|
||||
} else {
|
||||
print("There was an error decoding the date string")
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15,14 +15,55 @@ struct YapsFileCell: View {
|
||||
var yapsFile : YapsFile
|
||||
|
||||
var body: some View {
|
||||
|
||||
Group {
|
||||
HStack {
|
||||
// Icon
|
||||
FinderHelper.shared.getImageByFiletype(file: yapsFile.file).resizable().frame(width: 20, height: 20)
|
||||
|
||||
// Text
|
||||
Text("#\(yapsFile.index) \(yapsFile.name)")
|
||||
.foregroundColor(self.focused ? .blue : .gray)
|
||||
VStack(alignment: .leading) {
|
||||
// Dateiname
|
||||
Text("\(yapsFile.name)")
|
||||
.foregroundColor(self.focused ? .blue : .primary)
|
||||
.multilineTextAlignment(.leading)
|
||||
.lineLimit(1)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
|
||||
// Details
|
||||
Text(
|
||||
MiscHelper.shared.dateFormatDefault(inDate: FinderHelper.shared.getFileAttributes(yapsFile: yapsFile)[FileAttributeKey.modificationDate] as! Date)
|
||||
)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.leading)
|
||||
.lineLimit(1)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
}
|
||||
}
|
||||
}
|
||||
//.background(self.focused ? Color.gray : Color.clear)
|
||||
}
|
||||
}
|
||||
|
||||
struct YapsFileCell_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
VStack(alignment: .leading) {
|
||||
// Dateiname
|
||||
Text("dateiname.xyz")
|
||||
.foregroundColor(.primary)
|
||||
.multilineTextAlignment(.leading)
|
||||
.lineLimit(1)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
|
||||
// Details
|
||||
Text("xyz")
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.leading)
|
||||
.lineLimit(1)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
}
|
||||
}
|
||||
.background(/*@START_MENU_TOKEN@*/Color.gray/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user