Skip to content

Commit

Permalink
file size display text added
Browse files Browse the repository at this point in the history
  • Loading branch information
s4rv4d committed Aug 19, 2020
1 parent 047f3cf commit 3d06792
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docWind.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = docWind/docWind.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"docWind/Preview Content\"";
DEVELOPMENT_TEAM = N4FDL334LZ;
ENABLE_PREVIEWS = YES;
Expand All @@ -880,7 +880,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = docWind/docWind.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 3;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"docWind/Preview Content\"";
DEVELOPMENT_TEAM = N4FDL334LZ;
ENABLE_PREVIEWS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ struct GenListRowView: View {
VStack(alignment: .leading) {
Text(self.itemArray.wrappedItemName)
.font(.body)
Text(DWDateFormatter.shared.getStringFromDate(date: self.itemArray.wrappedItemCreated))
HStack {
Text(DWDateFormatter.shared.getStringFromDate(date: self.itemArray.wrappedItemCreated))
.font(.caption)
.foregroundColor(.secondary)
Spacer()
if URL(string: self.itemArray.wrappedItemUrl)!.fileSize != nil {
Text(NSString(format: "%.2f", URL(string: self.itemArray.wrappedItemUrl)!.fileSize!) as String + " MB")
.font(.caption)
.foregroundColor(.secondary)
}
}
}
.padding()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ struct NormalListRowView: View {
Text(self.itemArray.wrappedItemName)
.font(.body)
.lineLimit(1)
Text(DWDateFormatter.shared.getStringFromDate(date: self.itemArray.wrappedItemCreated))
HStack {
Text(DWDateFormatter.shared.getStringFromDate(date: self.itemArray.wrappedItemCreated))
.font(.caption)
.foregroundColor(.secondary)
Spacer()
if URL(string: self.itemArray.wrappedItemUrl)!.fileSize != nil {
Text(NSString(format: "%.2f", URL(string: self.itemArray.wrappedItemUrl)!.fileSize!) as String + " MB")
.font(.caption)
.foregroundColor(.secondary)
}
}
}
.padding()

}.contextMenu {
}
.contextMenu {
if self.itemArray.wrappedItemType == DWPDFFILE {
Button(action: {
self.selectedItem = self.itemArray
Expand Down
12 changes: 12 additions & 0 deletions docWind/Helpers/Helper+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,15 @@ extension String {
static func >=(lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) != .orderedAscending }
}

extension URL {
var fileSize: Float? {
if let value = try? resourceValues(forKeys: [.fileSizeKey]){
// need to convert into MB, mul with 0.000001
guard let floatVal = value.fileSize else { return nil }
let mbVal = Float(floatVal) * 0.000001
return mbVal
} else {
return nil
}
}
}

0 comments on commit 3d06792

Please sign in to comment.